简体   繁体   English

PHP strtotime不适用于日期和星期几

[英]PHP strtotime not working for date and day of week

Here's an odd one... pretty sure this is a strtotime issue, but would love some assistance as to why this would be partially working... 这是一个奇怪的问题...可以肯定这是一个strtotime问题,但是希望获得一些帮助,以了解为什么它会部分起作用...

CODE: 码:

$dateReturnedFromMySQL = '2014-09-22 18:00:00'
$startDate = strtotime( $dateReturnedFromMySQL );
$startMonth = date( 'M', $startDate );
$startDate = date( 'd', $startDate );
$startDay = date( 'D', $startDate );
$startFullDate = date('M d, Y', $startDate );

The variables $startMonth, $startDate are outputted correctly. 变量$ startMonth,$ startDate正确输出。 (Sep, 22 respectively) (分别为9月22日)

The variable $startFullDate returns as Dec 31, 1969 (clearly a strtotime issue, but not sure why?) 变量$ startFullDate返回为1969年12月31日(显然是strtotime问题,但不确定为什么吗?)

The variable $startDay always returns as Wed (again, clearly a strtotime issue, but not sure why?) 变量$ startDay始终返回为Wed(同样,显然是strtotime问题,但不确定为什么吗?)

You are overwriting your original variable: 您正在覆盖原始变量:

$startDate = date( 'd', $startDate );
^^^^^^^^^^ here

You should use a different name for that. 您应该为此使用其他名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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