Page 1 of 1

strtotime

Posted: Wed Apr 12, 2006 8:31 pm
by Sculpture
Hello,

Good grief...!

I have tried on several occasions to get my head around this one but to no avail. This is a piece of code that found on this forum.

Code: Select all

<?php
$currentdate = getdate(time());
$ausZone = strtotime('+ 15 hours',$currentdate);
?>
and imbedded in the body, in a hidden field in the body of html

Code: Select all

<input name="date" type="hidden" value="<?php echo "Application was lodged on ".$ausZone["wday"]." ".$ausZone["month"]." ".$ausZone["year"];?>">
Unfortunately it doesn't add fifteen hours to the timestamp.

Thanks ahead to anybody that can point me in the right direction.

Posted: Wed Apr 12, 2006 8:54 pm
by feyd
strtotime() doesn't accept getdate() output, but it does work with unix timestamps.

Posted: Thu Apr 13, 2006 9:39 pm
by Sculpture
OK... new tact.

Let's say the server hosting the web site is in Texas and the people looking at the web site and retrieving the data are in Australia. They want to know when the form was submitted at the right time.

Has anybody got a straight forward, one size fits all, method to insert an adjusted the time at the Australian timezone, using PHP4?

Thanks

Posted: Thu Apr 13, 2006 9:44 pm
by timvw
I would store everything in gm time ... and calculate the offset for us and au timezones (if i'm not mistaken strtotime is capable of doing this).

Posted: Fri Apr 14, 2006 1:09 am
by Sculpture
Yes thank you so much!

gmdate
ttech5593 at gmail dot com
29-Mar-2006 09:53
For me most of the examples here needed the + or - seconds to set the time zone. I wanted a faster way to get the time zone in seconds. So I created this :

Code: Select all

<?php 
$h = "3";// Hour for time zone goes here e.g. +7 or -4, just remove the + or -
$hm = $h * 60; 
$ms = $hm * 60;
$gmdate = gmdate("m/d/Y g:i:s A", time()-($ms)); // the "-" can be switched to a plus if that's what your time zone is.
echo "Your current time now is :  $gmdate . ";
?>
It works. Hope it helps.

You showed me the way and it works. :D