简体   繁体   中英

How to calculate the date of next Monday in PHP?

I'm trying to get a date that comes next Monday at night 00:01 am. I'm using the following lines:

date('Y-m-d h:i:s', strtotime(**'next monday, 01:01am'**, strtotime(date("Y-m-d h:i:s"))))

This gives me the proper output:

2014-05-19 01:01:00

But if I try to write:

date('Y-m-d h:i:s', strtotime(**'next monday, 00:01am'**, strtotime(date("Y-m-d h:i:s"))))

I'm getting:

1970-01-01 05:30:00

Please tell me what is wrong here.

00:01 am is not correct Use 12:01 am

Try this:

date('Y-m-d h:i:s', strtotime('next monday, 12:01am', strtotime(date("Y-m-d h:i:s"))));

It will give you 2014-05-19 12:01:00

Demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM