Reputation: 2243
Here's what i did -:
1360756718
seconds.19800
secondsBut unfortunately, the answer was 1 hour
ahead of original time. And I mean exactly 1 hour
. Result was 13 Feb 2013 18:28:38
which should have been 13 Feb 2013 17:28:38
.
Where am I worng?
Upvotes: 0
Views: 150
Reputation: 145
the other answers say you should check and correct your timezone settings. I would do that because it's more correct (regarding to daylight saving time and so on).
If you want to have the easy way try gmdate function:
string gmdate ( string $format [, int $timestamp = time() ] )
This one will always calculate in GMT - you don't have to check the server settings. (However it will ignore Daylight Saving Time too.)
Upvotes: 0
Reputation: 3143
You could try adding:
ini_set('date.timezone', 'My/Timezone');
Since php 5.1 it's also possible to do:
date_default_timezone_set ( string $timezone_identifier )
http://www.php.net/manual/en/function.date-default-timezone-set.php
To set the time to your own timezone. The timezones that are available for php are here:
http://www.php.net/manual/en/timezones.php
Upvotes: 0
Reputation: 1815
Please check your current timezone first. Here you can check all supported timezones as well
Upvotes: 1
Reputation: 8030
echo date( 'd.m.Y H:i:s', '1360756718' ); // 13.02.2013 13:58:38
echo date( 'd.m.Y H:i:s', ( '1360756718'+19800 ) ); // 13.02.2013 19:28:38
For me this came out as planned. Are you sure that you started with the right time? As some already mentioned, the problem most likely lies in your timezone or daylight savings time.
Upvotes: 1
Reputation: 5608
Well, you are in +5:30 but with daylight savings time, we still are 1 hour back. so you now are only +4:30
Upvotes: 3
Reputation: 6909
I think your timezone is set incorrectly. You need to dig around your Apache/PHP/Mysql settings to find out what it is set to.
Upvotes: 1