Jump to content

date(); -> Server time changes


Fsoft

Recommended Posts

Hey,

 

Using date(); function, caching time and date works cool but when I upload to server and try the script, it shows the time, date of Server "US time and date".. But I want it to show the date / time of local, it means it should detect from computer it's Time Zone and show the time and date of that,

 

Could any one help me regarding to this??

 

Thanks,

F@!$@L

Link to comment
https://forums.phpfreaks.com/topic/126112-date-server-time-changes/
Share on other sites

'local' date/time for the user can only be obtained from the user's computer (so javascript can take care of that).

 

If you can persuade each user to tell you what their offset is from GMT, then you could do the math on your server and tell them what time it is where they are.  But why would you want to?  I know what time it is here (it's in the bottom right corner of my screen, on my phone, on my wrist, on my microwave, etc. etc.)

'local' date/time for the user can only be obtained from the user's computer (so javascript can take care of that).

 

If you can persuade each user to tell you what their offset is from GMT, then you could do the math on your server and tell them what time it is where they are.  But why would you want to?  I know what time it is here (it's in the bottom right corner of my screen, on my phone, on my wrist, on my microwave, etc. etc.)

 

HEHEHE nice one , you know what time is it :D :D :D

 

Well, I want to know this because of ; http://www.phpfreaks.com/forums/index.php/topic,218528.msg1000970.html#msg1000970

 

As mentioned in this post, can you please tell me using a small code, how can I take a users time and write into Database, and then after 20 Mins can delete that entry,

 

Thanks, and hope will help me..

 

FAISAL!

As mentioned in this post, can you please tell me using a small code, how can I take a users time and write into Database, and then after 20 Mins can delete that entry,

 

If you re-read that, the answer's right there.  You don't actually care what the user's time is; all you care about is whether a user entry is older than 20 minutes.  If you user the server time in the database, you can compare the value in the database with the 'current' time on the server with nary a care about the user's time offset from your server time.

As mentioned in this post, can you please tell me using a small code, how can I take a users time and write into Database, and then after 20 Mins can delete that entry,

 

If you re-read that, the answer's right there.  You don't actually care what the user's time is; all you care about is whether a user entry is older than 20 minutes.  If you user the server time in the database, you can compare the value in the database with the 'current' time on the server with nary a care about the user's time offset from your server time.

 

well ya, you do have a point,

 

But the comparission will be how? I mean how can I compare time, as it's not number so that I can compare with... Time is in a special form of 13:03:07 How will I compare that :(.......?

 

FAISAL!

The query to do this is trivial. Which is why reading a basic mysql book to get up to speed with the basics is important in being able to accomplish any thing in mysql. TS in the following is a mysql TIMESTAMP (yyyy-mm-dd hh:mm:ss) that is inserted/updated along with the user's id on each page request.

 

$limit = 300; // if last access is less than this number of seconds ago, consider an id to be online

// determine who was but is not now online (ts older than the current time - limit) -
$query = "SELECT id FROM table_name WHERE ts < DATE_SUB(NOW(),INTERVAL $limit SECOND)";

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.