cows Posted October 16, 2006 Share Posted October 16, 2006 Hi,I am pretty new to php and I have a problem I can't quite figure out. I am not sure if I am misunderstanding the date() function or there is something else I am missing. I have this time stamp: [b]1159660803[/b]In the time stamp converter it says [b]Sun, 1 Oct 2006 00:00:03 UTC[/b]When i try get that from the date() function using [code]date('l dS \of F Y h:i:s A', 1159660803);[/code]I get a date/time and hour out ([b]Sunday 01st of October 2006 01:00:03 AM[/b])I need to get the time in the time stamp, is there something I am doing wrong or not quite understanding? The server is in the UK if that makes any difference.Any help would be appreciated, I have spent all night trying to figure out what I am doing wrong. :( Quote Link to comment https://forums.phpfreaks.com/topic/24064-date-function-problems/ Share on other sites More sharing options...
trillion Posted October 16, 2006 Share Posted October 16, 2006 what output are you looking for exactly? do you want this part: 01:00:03 AMto look like this: 00:00:03 UTC Quote Link to comment https://forums.phpfreaks.com/topic/24064-date-function-problems/#findComment-109327 Share on other sites More sharing options...
cows Posted October 16, 2006 Author Share Posted October 16, 2006 Yes, sorry. I need it to read [b]00:00:03[/b]. Quote Link to comment https://forums.phpfreaks.com/topic/24064-date-function-problems/#findComment-109329 Share on other sites More sharing options...
pndof12006 Posted October 16, 2006 Share Posted October 16, 2006 use this excat code[code] <? echo date('i:s', 1159660803);?>[/code]or if you need the hour in there use this:[code]<? echo date('h:i:s', 1159660803);?>[\code][/code] Quote Link to comment https://forums.phpfreaks.com/topic/24064-date-function-problems/#findComment-109335 Share on other sites More sharing options...
akitchin Posted October 16, 2006 Share Posted October 16, 2006 .. that doesn't solve his problem at all.i imagine it's just a one-hour offset between server time and the timezone you expect it to be in. try adding "O" (uppercase o) to your date() function and see if the server spits back UTC or if it's off of GMT. Quote Link to comment https://forums.phpfreaks.com/topic/24064-date-function-problems/#findComment-109339 Share on other sites More sharing options...
xsist10 Posted October 16, 2006 Share Posted October 16, 2006 [url=http://www.php.net/date]http://www.php.net/date[/url]e Timezone identifier (added in PHP 5.1.0) Examples: UTC, GMT, Atlantic/Azores Quote Link to comment https://forums.phpfreaks.com/topic/24064-date-function-problems/#findComment-109373 Share on other sites More sharing options...
akitchin Posted October 16, 2006 Share Posted October 16, 2006 keep in mind (as xsist's post itself says) that 'e' will only work for fairly new versions of PHP. Quote Link to comment https://forums.phpfreaks.com/topic/24064-date-function-problems/#findComment-109374 Share on other sites More sharing options...
cows Posted October 16, 2006 Author Share Posted October 16, 2006 Thank you.I never realised the date function formatted the dates using the server's time zone settings and daylight saving settings. I thought it would format the date as-is, UCT.Is there anyway I can get the formatted date in UCT with that date function or another function? Quote Link to comment https://forums.phpfreaks.com/topic/24064-date-function-problems/#findComment-109379 Share on other sites More sharing options...
xsist10 Posted October 16, 2006 Share Posted October 16, 2006 Read the manual entry at [url=http://www.php.net/date]http://www.php.net/date[/url]. If it doesn't help you then check out the posts below it. You'll normally find your solution in the user posted comments.This may work....[code]<?phpecho date('D, j M Y h:i:s', 1159660803 - date('Z'));// ordate_default_timezone_set('UTC');echo date('D, j M Y h:i:s', 1159660803)?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/24064-date-function-problems/#findComment-109381 Share on other sites More sharing options...
cows Posted October 16, 2006 Author Share Posted October 16, 2006 [quote author=xsist10 link=topic=111620.msg452463#msg452463 date=1160988210]This may work....[code]<?phpecho date('D, j M Y h:i:s', 1159660803 - date('Z'));// ordate_default_timezone_set('UTC');echo date('D, j M Y h:i:s', 1159660803)?>[/code][/quote]The first solution worked perfectly. Thank you very much. I didn't want to use the date_default_timezone_set() because the server doesn't support that yet.Thank you for all the replies, they are much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/24064-date-function-problems/#findComment-109385 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.