Jump to content

Time problem


smiles

Recommended Posts

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

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

... 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

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

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

Archived

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

×
×
  • Create New...