Its a bit of a sever difference problem. On my local dev. server Im using:
<?php print strtotime($date." UCT"); ?>
The above code gives me the correct timestamp for my timezone. HOWEVER, the same code returns false on the live server.
The live server has a lower version of php installed and I imagine that to be the problem.
What I'm looking for is an alternative to the above line of code.
I could use the normal strototime without the ." UCT" part and add in 2hours but would rather have PHP handle timezones.
$date looks like this: 2011-05-25 05:48:00
PHP strtotime() function returns a timestamp value for the given date string. Incase of failure, this function returns the boolean value false.
Code for converting a string to dateTime$date = strtotime ( $input ); echo date ( 'd/M/Y h:i:s' , $date );
strtotime expects a "English textual datetime" (according to the manual), which Y-D-M is not. Any time strtotime returns false, it simply doesn't understand your string, which in this application is expected.
If you want to use the PHP function strtotime to add or subtract a number of days, weeks, months or years from a date other than the current time, you can do it by passing the second optional parameter to the strtotime() function, or by adding it into the string which defines the time to parse.
<?php print strtotime($date." UTC"); ?>
instead of
<?php print strtotime($date." UCT"); ?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With