Mathematicman Posted September 3, 2007 Share Posted September 3, 2007 Hi all I'm still kind of new at php... so this may be a dumb question... I had set up a php document that involved the time... So I put it together something like this: <?php $H= date("H")-6; $col= ":"; $M= date("i"); $T= "$H$col$M"; echo $T; ?> That may not be the best way to do it... but I wasn't getting any error reports that way (and I needed it in a 24 hour format)... My problem/question, is how do I do time zones? the "date("H")-6" thing doesn't work, at times you get "-3:00", not really useful... so how do I do it so it's on my time zone? Thanks for your help... Quote Link to comment https://forums.phpfreaks.com/topic/67723-solved-time-zones/ Share on other sites More sharing options...
hvle Posted September 3, 2007 Share Posted September 3, 2007 the time returned $T is the time at the city where your host server located. So if your host is in New York, it would return EDT. So for instance, you are living California (time zone - and your host server located in NY (time zone -5), then the offset you need to add to the "hours" would be -8 - (-5) = -3 so Base on your code: <?php $timeOffset = -3 $H= date("H") + $timeOffset; $col= ":"; $M= date("i"); $T= "$H$col$M"; echo $T; ?> Be aware the make change to your code if the hours is negative. Quote Link to comment https://forums.phpfreaks.com/topic/67723-solved-time-zones/#findComment-340260 Share on other sites More sharing options...
Mathematicman Posted September 6, 2007 Author Share Posted September 6, 2007 Ok... so here's what I have... My time zone is 6 hours from what my server’s time zone is... So here's my code: <?php $timeOffset = -6 $H= date("H") + $timeOffset; $col= ":"; $M= date("i"); $T= "$H$col$M"; echo $T; ?> It’s 9:14 right now and the page reads "-3:14" is the negative supposed to be there? Can I change it or is it as good as it gets? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/67723-solved-time-zones/#findComment-342674 Share on other sites More sharing options...
trq Posted September 6, 2007 Share Posted September 6, 2007 <?php echo date('H:i',mktime(date('H')-6,date('i'))); ?> Quote Link to comment https://forums.phpfreaks.com/topic/67723-solved-time-zones/#findComment-342707 Share on other sites More sharing options...
Mathematicman Posted September 6, 2007 Author Share Posted September 6, 2007 there we go... now that works... thanks Quote Link to comment https://forums.phpfreaks.com/topic/67723-solved-time-zones/#findComment-343134 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.