Jump to content

[SOLVED] date() and hours in the day


Lodius2000

Recommended Posts

Im not too good with math so this may need to go in the math section, feel free to move

 

I have a series of dropdown menus for the date and time, the one for hours has a default of (date('G')-2) because myserver is on eastern time (EDT) and I live in Mountain time (MDT), so  I subtract two from the hour. the problem is after 10pm MDT, the server says its midnight (0) so you cant subtract 2 from 0 and get 22 (or 23 for 11pm MDT) so after 10pm MDT, the dropdown menu says 0 until 1am MDT becuase at that time the server is at 3am EDT and can this subtract 2 to get a time other than 0

 

Question:

 

how do I set up an equasion where 0-2=22 or 1-2=23?

 

i have no ideas

 

as always, appreciate the help

Link to comment
https://forums.phpfreaks.com/topic/112293-solved-date-and-hours-in-the-day/
Share on other sites

Might work better by simply using date with

 

date_default_timezone_set()

(http://www.php.net/manual/en/function.date-default-timezone-set.php)

 

Or, you could look into strtotime("-2 hours")

(http://www.php.net/manual/en/function.strtotime.php)

 

Probably two of the simplest ways of going about it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.