Page 1 of 1
stupid timestamp!
Posted: Wed May 12, 2004 3:57 pm
by tim
okay, for the third time
what is wrong with this? I want the timezone to be the exact same as here in OHIO!
This was working correctly for the longest time, now when I use it, its an hour off!?!?
WHATTTTTTT in the sam hell is wrong with this POS? grr grr
$time = date('g:i A', (time()-(23*60*60)));
Posted: Wed May 12, 2004 4:12 pm
by launchcode
Whoa.. what on earth is all that date/time() foo for? Save yourself the hassle... do it the easy way:
Code: Select all
$ohio_time = strtotime("-5 hours");
This assumes that the server the script is running on is 5 hours ahead of what you need. Adjust the "time" accordingly if not.
Posted: Wed May 12, 2004 4:43 pm
by tim
I know, i'm not dumb
perhaps I was unclear thou, sorry.
I wish to display the time, this is for a blog type deal.
i want it to be like: posted by _____ at _:__ AM/PM
confusing to why it worked now is off, hmm hmm...
Posted: Wed May 12, 2004 5:47 pm
by launchcode
Yeah, so:
Code: Select all
echo date('g:i:A', strtotime("-5 hours"));
Posted: Wed May 12, 2004 6:37 pm
by Weirdan
tim wrote:
Code: Select all
$time = date('g:i A', (time()-(23*60*60)));
I bet it worked before DST came into effect

Posted: Wed May 12, 2004 6:43 pm
by launchcode
Heh.. yeah. Should never rely on all that *60 crap for dates, they're far too fussy for that to work all the time!
Posted: Wed May 12, 2004 7:34 pm
by tim
okay
it works (so far) but my last two worked for a little bit as well.. this one dont seem much complicated so I hope it holds true
i had to format it like this:
$time = date('g:i:A', strtotime("-0 hours"));
thank you!
Posted: Wed May 12, 2004 7:37 pm
by tim
Weirdan wrote:
I bet it worked before DST came into effect

and no, I would have thought on that. After daylight savings time came into effect I coded it, and it worked til 2 days when I noticed the stamp was off an hour (out of the blue)
hence why it boggles my mind
oh well!
Posted: Wed May 12, 2004 7:41 pm
by launchcode
If you don't need to modify the timestamp, don't bother with the strtotime() part at all!
Heck, you don't even need the time() part as it'll assume it by default!
The above will work just fine (does here anyway). Check that the time setting on your server is actually correct and hasn't been messed up somehow? Might be your hosts fault rather than anything else.
Posted: Wed May 12, 2004 7:48 pm
by tim
yes that works (duh I am dumb

)
but I also was searching for a easy-to-modify command line for time
I wish to create a function to arrange the time so people can set the desired timezone in their profile, so I think the above will work
kudos
Posted: Wed May 12, 2004 7:53 pm
by launchcode
You could use some Javascript to get their local time, pass it to a PHP script and then determine the offset (from the server time) automatically? It's a nice and friendly way to do it anyway
