Page 1 of 1

How to set PHP time?

Posted: Wed Nov 19, 2008 5:08 pm
by intellivision
My server's time is dead on (Cent OS via Plesk). But when I do a

Code: Select all

<?php echo(date('m-d-Y h:s',time())); ?>
I get a time that's about 24 minutes in the future. :?

Any ideas?

Re: How to set PHP time?

Posted: Wed Nov 19, 2008 5:13 pm
by intellivision
Whoa... I just ran that code again four times in one minute and got the following:

11-19-2008 04:01
11-19-2008 04:45
11-19-2008 04:59
11-19-2008 04:25

So strike the bit about 24 minutes. My PHP time is drunk.

Re: How to set PHP time?

Posted: Wed Nov 19, 2008 5:14 pm
by andyhoneycutt
Your date formatting is off, try:

Code: Select all

 
// Wrong (month, day, year, hours, seconds:
echo(date('m-d-Y [color=#FF0000]h:s[/color]',time()));
// Right: (month, day, year, hours, minutes:
echo(date('m-d-Y [color=#00BF00]h:i[/color]',time()));
-Andy

Re: How to set PHP time?

Posted: Wed Nov 19, 2008 5:23 pm
by intellivision
Andy, thanks!

I think I was randomizing or something. Oy vey. Gracias.

Re: How to set PHP time?

Posted: Wed Nov 19, 2008 5:24 pm
by andyhoneycutt
No problem, next time instead of blaming your php for being drunk, you might want to take a breathalyzer youself :)