Wern Ancheta
Wern Ancheta

Reputation: 23317

cannot get the correct date and time in php

I dont know why I'm not getting the correct date and time in my region. Here's the code

<?php
//date_default_timezone_set('Asia/Manila');
echo date('YYYY-mm-dd H:i:s'); ?>

Even if I comment out or change the time zone the date and time that I'm getting is still the same. The date today is 23. But its outputting 22. And the time doesn't change even if I change the time zones. Does it have something to do with my computer? Because I sometimes notice that the clock on the lower right corner of the screen is not displaying the correct time.

Heres the current time, but its displaying this:

01-22-2011 05:38:31-PM

alt text

Upvotes: 0

Views: 473

Answers (3)

archaeusz
archaeusz

Reputation: 41

Are you from the Philippines? This worked for me for some reason:

date_default_timezone_set('Asia/Tbilisi');

Asia/Manila is not working for me too. Just give it a try.

Upvotes: 0

RichardTheKiwi
RichardTheKiwi

Reputation: 107806

Are you sure that's the script producing the output shown?

echo date('YYYY-mm-dd H:i:s'); ?>

Doesn't seem to match the format of

01-22-2011 05:38:31-PM

Other than that, the timezone setting looks right.

Upvotes: 1

mike.dld
mike.dld

Reputation: 3049

It could be that time set up on server (where PHP script is being executed) is not correct.

Upvotes: 1

Related Questions