Lodius2000 Posted June 28, 2008 Share Posted June 28, 2008 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 More sharing options...
Nhoj Posted June 28, 2008 Share Posted June 28, 2008 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. Link to comment https://forums.phpfreaks.com/topic/112293-solved-date-and-hours-in-the-day/#findComment-576527 Share on other sites More sharing options...
Lodius2000 Posted June 28, 2008 Author Share Posted June 28, 2008 so do I do it like this date_default_timezone_set(America/Denver); thats what i cam up with and I got a warning error "Warning: Division by zero in /index.php on line 3" line 3 is where i put the above timezone line Link to comment https://forums.phpfreaks.com/topic/112293-solved-date-and-hours-in-the-day/#findComment-576533 Share on other sites More sharing options...
kenrbnsn Posted June 28, 2008 Share Posted June 28, 2008 The function is expecting the parameter to be a string, so you need to put it in quotes: <?php date_default_timezone_set('America/Denver'); ?>[/code[ Ken Link to comment https://forums.phpfreaks.com/topic/112293-solved-date-and-hours-in-the-day/#findComment-576537 Share on other sites More sharing options...
Lodius2000 Posted June 28, 2008 Author Share Posted June 28, 2008 <------hates self DUH Works perfectly Link to comment https://forums.phpfreaks.com/topic/112293-solved-date-and-hours-in-the-day/#findComment-576539 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.