|
Posted by Toby A Inkster on 04/23/07 15:22
Rolf Mander wrote:
> <?
> echo date("d",time());
> echo date("m",time());
> echo date("Y",time());
> ?>
Consider running this code at the stroke of midnight on Monday/Tuesday
next week.
<?
/* Today is Monday 30 April 2007 */
echo date("d",time());
/* It's midnight now. Clocks go 23:59:59 => 00:00:00. */
/* Today is Tuesday 1 May 2007 */
echo date("m",time());
echo date("Y",time());
?>
Outputs: 30052007
The other code you posted:
> <?
> $time = time();
> echo date("d",$time);
> echo date("m",$time);
> echo date("Y",$time);
> ?>
Doesn't suffer from that problem. It's also probably faster, but unless
you're doing it thousands of times in a loop, you won't notice any
difference.
--
Toby A Inkster BSc (Hons) ARCS
http://tobyinkster.co.uk/
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux
* = I'm getting there!
Navigation:
[Reply to this message]
|