This can be usefull for people that are switching from PHP4 to PHP5, be carefull when you use the strtotime-function
In PHP 4.4.6 following code return equal timestamps, as in PHP 5.1.4 they return other timestamps
PHP 4.4.6
<?php
// returns the current timestamp (25/09/2007 20:21:52)
echo date('d/m/Y H:i:s', strtotime('today'));
// returns the current timestamp (25/09/2007 20:21:52)
echo date('d/m/Y H:i:s', strtotime('now'));
?>
PHP 5
<?php
// returns the current date at midnight (25/09/2007 00:00:00)
echo date('d/m/Y H:i:s', strtotime('today'));
// returns the current timestamp (25/09/2007 20:21:52)
echo date('d/m/Y H:i:s', strtotime('now'));
?>
Same results, but don't using the strtotime-method
<?php
// returns the current date at midnight (25/09/2007 00:00:00)
echo date('d/m/Y H:i:s', mktime(0,0,0));
// returns the current timestamp (25/09/2007 20:21:52)
echo date('d/m/Y H:i:s') ;
?>
Reacties
Frank schreef:
26/09/07
T is typisch php om dat zo "laat" in de taal (4 -> 5) te gaan veranderen, maar eigenlijk is het logischer zo.
arun schreef:
27/05/10
its very helpful for begginers