Forum Moderators: coopster

Message Too Old, No Replies

unix timestamp

         

adammc

12:47 am on Jan 17, 2007 (gmt 0)

10+ Year Member



Hi guys,

A script I am using is fetching the servers time and placing it into the DB using this:
$timeNow = date("U");

My question is, how can I format this to 'my' local timezone?

adammc

1:32 am on Jan 17, 2007 (gmt 0)

10+ Year Member



To better explain...

I need to convert the sewrver timestamp into my loal times timestamp (+10)

phranque

1:56 am on Jan 17, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



what is
'my' local timezone
?
you might want to look at the localtime function:
[php.net...]

if you mean local to the browser, that's a different issue...

adammc

2:14 am on Jan 17, 2007 (gmt 0)

10+ Year Member



Sorry, I meant that I wanted to change it into a (+10) offset timestamp

adammc

2:33 am on Jan 17, 2007 (gmt 0)

10+ Year Member



$timeNow = date("U") + (10 * 60 * 60);

I have tried this, but the result was a time 6hours behind.

barns101

9:28 am on Jan 17, 2007 (gmt 0)

10+ Year Member



You could use mktime() [php.net] and then format the output using date() [php.net].

$timeNow = mktime() + 36000; // Time now plus 10 hours (expressed in seconds)
echo date("j F Y", $timeNow);