smiles Posted May 11, 2007 Share Posted May 11, 2007 my friends posting in our class's forum, click Submit button, ... but the time of their posts is the time of server$datetime = date("h:m:i");how can I adjust to the local time, means the time on their computer ???I think of Javascript, but not find out the way for submiting the time of posting ???thanks !!! Link to comment Share on other sites More sharing options...
reportingsjr Posted May 11, 2007 Share Posted May 11, 2007 Check out http://www.php.net/manual/en/function.date...imezone-set.php, or http://www.php.net/manual/en/function.date-timezone-set.php. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 11, 2007 Share Posted May 11, 2007 To point out, you want it to submit with the server's timestamp. If you don't, the posts won't show up in order. Imagine what a thread would look like on here if they were ordered by the local time of each user who posted. Save the post using the server's time, but you can have a preference for the users to choose their time zone, and when you display the time, then you can add or remove hours to get it to the user's time zone. Link to comment Share on other sites More sharing options...
smiles Posted May 12, 2007 Author Share Posted May 12, 2007 ... Save the post using the server's time, but you can have a preference for the users to choose their time zone, and when you display the time, then you can add or remove hours to get it to the user's time zone.Add and remove hours ? By which way Link to comment Share on other sites More sharing options...
MildewMan1 Posted May 14, 2007 Share Posted May 14, 2007 if the person you want to change it for is 1 hour ahead, you could order it by the server's TS, add 1 hour to it, and then redisplay it for the person. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 14, 2007 Share Posted May 14, 2007 Look at the Date/Time function reference on php.net, there are functions to do this. You will want to convert the dates from the database into timestamps using a function like mktime, which will convert the time into seconds, and then you can add seconds to the timestamp and convert it back to a readable format. If the user's timezone was +4, then to add 4 hours to the timestamp, in seconds, would be 4 * 60 * 60. Link to comment Share on other sites More sharing options...
smiles Posted May 15, 2007 Author Share Posted May 15, 2007 Thanks for your help !!! I found it out !!! Mktime() $datetime=date("d/m/y H:i:s",mktime(date("H"),date("i"),date("s")-7*60*60,date("m"),date("d"),date("y"))); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.