tronicsmasta Posted May 8, 2008 Share Posted May 8, 2008 Hey guys, I would like to use the date() function to input the date into the database but I noticed it goes by the servers time... Is there a way to put in the users date time and timezone so I don't have to ask them their timezone store it in a cookie and then do something like this: eg just an example $date = date("M j, Y g:i a") + timezone offset?; Link to comment https://forums.phpfreaks.com/topic/104660-user-date-and-time/ Share on other sites More sharing options...
moselkady Posted May 8, 2008 Share Posted May 8, 2008 I am not sure you can get the user's date and time from the server side. You probably need to use Javascript to get the desired date/time then pass that to your PHP script. For example, this Javascript code puts the date/time string into a hidden field of a form and when the user submits the form to PHP code, the date/time is passed along: <form action="some_script.php" method="post" onSubmit="filldate(this)"> <input type="hidden" name="datetime"> Enter you name <input type="text" name="fullname"> <input type="submit" value="send"> </form> <script> function filldate(frm) { today = new Date(); frm.datetime.value = today.toString(); } </script> You check the Javascript Date() object for more properties that can fit your purpose. Link to comment https://forums.phpfreaks.com/topic/104660-user-date-and-time/#findComment-535724 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.