How to change Mountain Time to East Coast Time in PHP code

  • Mark709
  • Novice
  • Novice
  • Mark709
  • Posts: 22

Post 3+ Months Ago

I have my hosting server showing/displaying and SAVING RECORDS in US Mountain Time
.
NOW I wish to SAVE MY RECORDS IN US EAST COAST TIME (New York)
as far as I can tell the code relating to time is as follows
.
$tm=date('m/d/Y H:i:s' , time());
then it seems to save $tm -- as $tm is INSERT INTO the table name
.
then after saving a courtesy screen appears and advises the user
Todays Date is -- : <?php echo date('m/d/Y', $time); ?>
then displays
Time Saved - New York time
: <?php echo date('H:i:s', $time); ?>
.
Can someone please advise how to MODIFY THIS CODE
to SAVE and DISPLAY as time in "New York Time" (when saved and displayed).
.
Many thanks
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

All you have to do is add two hours to what time that your server returns.

Code: [ Select ]
$tm=date('m/d/Y H:i:s' , time() + 60*60*2);


There are 60 seconds in a minute, 60 minutes in an hour and your looking for 2 hours.

Anywhere you see time() you want to add 60*60*2.

Or you can use date_default_timezone_set("America/New_York");
  • Mark709
  • Novice
  • Novice
  • Mark709
  • Posts: 22

Post 3+ Months Ago

Many, many thanks for this - it works like a charm.
This has been SO HELPFUL to me.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 139 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.