简体   繁体   中英

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...

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. (Sep, 22 respectively)

The variable $startFullDate returns as Dec 31, 1969 (clearly a strtotime issue, but not sure why?)

The variable $startDay always returns as Wed (again, clearly a strtotime issue, but not sure why?)

You are overwriting your original variable:

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

You should use a different name for that.

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