开发者

strtotime PHP function questions

开发者 https://www.devze.com 2023-03-22 04:00 出处:网络
I have a strtotime function that is doing something like this: $var = strtotime(\'23:59:59\' . $Date);

I have a strtotime function that is doing something like this:

$var = strtotime('23:59:59' . $Date);

Where $Date is a date in this form开发者_如何学Pythonat: MM/DD/YY

However, this randomly fails and returns nothing from it.... am I doing something wrong here?

Thanks.


You should add a space character to the end of your time string


It's not necessarily always the best way to accomplish date math, but note the very handy feature that strtotime() takes interval words too:

$var = strtotime($date . ' +1 day -1 second');

I.e., start at $date, add one day, then subtract one second. This gives you 23:59:59 for $date.

0

精彩评论

暂无评论...
验证码 换一张
取 消