Fsoft Posted September 27, 2008 Share Posted September 27, 2008 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 Quote Link to comment Share on other sites More sharing options...
ratcateme Posted September 27, 2008 Share Posted September 27, 2008 you could set the timezone on your pages to something for say the country you are in or where most of your visitors are from using date_default_timezone_set() but you need javascript to detect the users timezone. Scott. Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 27, 2008 Share Posted September 27, 2008 '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.) Quote Link to comment Share on other sites More sharing options...
Fsoft Posted September 27, 2008 Author Share Posted September 27, 2008 '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 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! Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 28, 2008 Share Posted September 28, 2008 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. Quote Link to comment Share on other sites More sharing options...
Fsoft Posted September 28, 2008 Author Share Posted September 28, 2008 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! Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 28, 2008 Share Posted September 28, 2008 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)"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.