I’m running a comment script, and i want to fix the time each post was added in.
While it was posted 19:21 in norway it were posted 20:21 somewhere else.
Something witch also makes a “time since” useless.
Do you understand the issue?
I’m basically i’m looking for a way to change the time to the local area of each user.
Could anyone provide me with a solution for my problem?
I’m currently using php, but i could go for javascript too.
I’ve seen a website use this code: document.write( GetElapsedTime( 1330160527 ) );
But then again, i have no idea of how i could get each time-value.
In Javascript,
new Date().getTime()returns the number of milliseconds since midnight Jan 1, 1970 local time, that is, based on the browser’s time zone. To convert this to the server’s time, the server must render the page with its own calculation of milliseconds elapsed since Jan 1, 1970, the you can use Javascript to convert the browser’s time to the server’s timezone, like this:Note that we round the time difference (in milliseconds) to the nearest half-hour because two different timezones must be at least half an hour apart, but never a smaller fraction of an hour.