Jump to content

date function problems


cows

Recommended Posts

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. :(
Link to comment
Share on other sites

.. 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.
Link to comment
Share on other sites

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?
Link to comment
Share on other sites

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]
<?php
echo date('D, j M Y h:i:s',  1159660803 - date('Z'));

// or

date_default_timezone_set('UTC');
echo date('D, j M Y h:i:s',  1159660803)

?>
[/code]
Link to comment
Share on other sites

[quote author=xsist10 link=topic=111620.msg452463#msg452463 date=1160988210]
This may work....
[code]
<?php
echo date('D, j M Y h:i:s',  1159660803 - date('Z'));

// or

date_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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.