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

Link to comment
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.)

 

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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)";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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