damo87 Posted March 29, 2010 Share Posted March 29, 2010 I am displaying a table of football matches, which includes columns for venue and date. The complete code is quite long, so I'll just show the relevant parts: $query="SELECT venue, date_format(datetime, '%M %e, %Y, %l:%i%p') as newdate,..... Then I define some variables from the query: while($nt=mysql_fetch_array($result)){//Array or records stored in $nt $datedisplay = $nt[newdate]; Then display the results in a table: echo "<tr><td class=right>$nt[hometeamname] $homefinalscore</td>.......<td class=center>$nt[venue]</td><td>$datedisplay</td>.......</tr>"; So I get my date/time displayed in the table like this: April 1, 2010, 7:40pm This is all working fine. All the dates are stored on the database in a particular time zone, which is the same time zone as my server time, which makes it easy to do things such as restrict changing selections for a game that has already started. What I would like to change though, is to display the game date/time in the local time for that game location. There are only two venues where the time zone is different, so I imagine I would need to do something like "if venue = S, $datedisplay=$datedisplay-2" (if the venue 'S' is two hours behind the server time.) Just to clarify, I am not looking to change the date displayed based on my users' location. Everyone, no matter their actual location should see the same game time displayed. Thanks in advance for any suggestions. Quote Link to comment https://forums.phpfreaks.com/topic/196926-decrement-date/ Share on other sites More sharing options...
ocpaul20 Posted March 30, 2010 Share Posted March 30, 2010 Cant you save the timezone, change it to do what you want, fiddle about with the dates/times and then change it back? date_default_timezone_set('GMT'); or whatever...? I always write a mickey-mouse program to test stuff like this and then put it into the main program when it is working in the mickey-mouse program. Quote Link to comment https://forums.phpfreaks.com/topic/196926-decrement-date/#findComment-1033905 Share on other sites More sharing options...
damo87 Posted March 30, 2010 Author Share Posted March 30, 2010 Thanks for the response, ocpaul20. I'm not familiar with 'date_default_timezone_set' so Ill have to do my research to fully understand how it could help. In the mean time, I have simply created a new date/time column in the database So I have one datetime column that is used to display the date on the page (which shows the game in the local time of the game location), while the other datetime column (which is the server time of the game start time) which is used to do other stuff, such as lock down any further tipping once the game has started. I really have no idea about whether this is a better solution than manipulating the dates with php . I suppose it is a better solution for me right now because it is the only way I know to get it to work. Quote Link to comment https://forums.phpfreaks.com/topic/196926-decrement-date/#findComment-1034017 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.