nats Posted December 21, 2008 Share Posted December 21, 2008 I am trying to upload files into MySQL database using PHP...& I've already done that..but I also want the current date & time of uploading to be stored in the database(the files can be uploaded from any terminal in an intranet). Now the problem here is that, the current date comes form the system's date & is the stored into the database...but different systems have different dates and none of them are consistent... Hence I wanted to know if there is a way out to avoid this whole mess... Quote Link to comment https://forums.phpfreaks.com/topic/137879-date-inconsistency-problems/ Share on other sites More sharing options...
chronister Posted December 21, 2008 Share Posted December 21, 2008 but different systems have different dates and none of them are consistent.. ??-- hmmm -- ?? I am stumped on this one. Is this a global application? Why do the different systems have different dates... and do you mean servers or the clients? It seems though, that your going to have to create a time offset for each user... i.e. let them choose their timezone. Then store that with the server's time and when it is displayed, use the offset to modify the timeshift. Nate Quote Link to comment https://forums.phpfreaks.com/topic/137879-date-inconsistency-problems/#findComment-720595 Share on other sites More sharing options...
RussellReal Posted December 21, 2008 Share Posted December 21, 2008 like nate suggests, there must be a user database where each user's information is stored.. E.G. Name, UserName, PassWord.. make everybody re-register.. but make a new field.. TimeZone field.. which would be like -5 -4 -3 -2 -1 0 1 2 3 4 5 than get your server's timezone, and calculate the difference.. either that.. or make your server's time the STANDARD time.. and let everybody know your server is for example.. -3GMT then when sum1 uploads it.. they'll know if they're -5GMT (like me) that if its 2:00 in the database for that file.. it was really uploaded @ 12:00.. furthermore.. instead of changing and shifting time, for each individual.. having 1 SET time, to gauge all the time measuring is more effective for a business/database anyway Quote Link to comment https://forums.phpfreaks.com/topic/137879-date-inconsistency-problems/#findComment-720606 Share on other sites More sharing options...
redarrow Posted December 21, 2008 Share Posted December 21, 2008 Can you show us how your posting the date please. It should be a time stamp. time(); Quote Link to comment https://forums.phpfreaks.com/topic/137879-date-inconsistency-problems/#findComment-720620 Share on other sites More sharing options...
nats Posted December 22, 2008 Author Share Posted December 22, 2008 This a an e-learning portal which is currently on an intranet level(i.e within the college campus)...wherein multiple users can login through different terminals...& the stuff which they upload is being stored into the server's database...(into a field called as Date_of_submission having type as DateTime) How do I enter the server's current date into the database while some user is trying to upload a file? Quote Link to comment https://forums.phpfreaks.com/topic/137879-date-inconsistency-problems/#findComment-721047 Share on other sites More sharing options...
Mark Baker Posted December 22, 2008 Share Posted December 22, 2008 Now the problem here is that, the current date comes form the system's date & is the stored into the database...but different systems have different dates and none of them are consistent... Hence I wanted to know if there is a way out to avoid this whole mess... Use one consistent data, that of the database. And get in the habit of ensuring that the correct date/time is maintained on your servers Quote Link to comment https://forums.phpfreaks.com/topic/137879-date-inconsistency-problems/#findComment-721200 Share on other sites More sharing options...
nats Posted December 23, 2008 Author Share Posted December 23, 2008 Well I liked the idea suggested by RusselReal... But since I am a beginner in php....I needed some more help... If someone could help me out with the code....It would be of great thanks.. Quote Link to comment https://forums.phpfreaks.com/topic/137879-date-inconsistency-problems/#findComment-721844 Share on other sites More sharing options...
RussellReal Posted December 24, 2008 Share Posted December 24, 2008 okay, nats Your server is a campus server.. this means that only computers on the SAME campus can access this via intranet.. now, unless your school is somehow EXACTLY where two time zones meet, than its pretty safe to say.. the server time will always be the server time.. wh ether uploaded from the guy in 1A or the girl in 2C. That being said.. whenever a file is uploaded.. set the `time` field to time() that will give a timestamp.. or you can do date("F jS, Y h:iA"); that will return something like June 3rd, 2008 12:32AM Quote Link to comment https://forums.phpfreaks.com/topic/137879-date-inconsistency-problems/#findComment-723009 Share on other sites More sharing options...
nats Posted December 24, 2008 Author Share Posted December 24, 2008 thanx Russell Well i had the same thing in my mind...but now i hav 1 more doubt.. is there ne way we can handle wrong dates set in the server machine.. coz my project has features where we have to store the date of post, date of submission etc.. if the server is set to a wrong date then the server time which will be stored in the database, will be wrong. So is there ne way to handle this problem (other than manually setting the correct date in the server) ? Quote Link to comment https://forums.phpfreaks.com/topic/137879-date-inconsistency-problems/#findComment-723046 Share on other sites More sharing options...
RussellReal Posted December 24, 2008 Share Posted December 24, 2008 the server will never set a wrong date.. Quote Link to comment https://forums.phpfreaks.com/topic/137879-date-inconsistency-problems/#findComment-723047 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.