Jump to content

[SOLVED] strtotime


The Little Guy

Recommended Posts

why doesn't this echo out the time stamp?

 

$bday = 07221986;
$bday = substr_replace($bday, ' ', 2, 0);
$bday = substr_replace($bday, ' ', 5, 0);

echo strtotime($bday);

 

OR

 

$bday = 19860722;
$bday = substr_replace($bday, ' ', 4, 0);
$bday = substr_replace($bday, ' ', 7, 0);

echo strtotime($bday);

Link to comment
https://forums.phpfreaks.com/topic/108731-solved-strtotime/
Share on other sites

In the first one, the substr_replace() is not doing what you think (echo $bday to see what it contains.)

 

In the second one, spaces between the fields are not one of the formats that strtotime() understands for yyyy-mm-dd and it returns a FALSE value. For this one, change the spaces to dashes -

Link to comment
https://forums.phpfreaks.com/topic/108731-solved-strtotime/#findComment-557585
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.