mem0ri Posted May 25, 2006 Share Posted May 25, 2006 The short of the problem:It doesn't seem (from an inexperienced eye) that there is any easy correlation between the way PHP records and reads time and the way MySQL records and reads time.My Difficulty:I want to record times at certain points in my PHP pages and store them in MySQL...in a format that can be read as a date/time and can be re-extracted and adjusted easily by PHP. Example:--On INSERT to the MySQL database, record the current date and time.--On query, display the previously recorded date and time in an easily readable format.--ON UPDATE to the MySQL database, take the previous time and add either x days or x weeks, etc.--On query...if a certain time has passed...spur another function.I know they're all essentially easy things to do...I'm just lost... Quote Link to comment https://forums.phpfreaks.com/topic/10453-datetime-in-php-mysql/ Share on other sites More sharing options...
nogray Posted May 25, 2006 Share Posted May 25, 2006 you can use the PHP time() and date() functions if the dates are not older the 1970.use time() when you insert the queryto display the time, use date("r", $time) use any format you want instead of the "r" and the $time will be the time you get from the database (the time you recorded).use mktime() function to update the query with the new timefor details on the functions search for them in [a href=\"http://www.php.net\" target=\"_blank\"]http://www.php.net[/a] Quote Link to comment https://forums.phpfreaks.com/topic/10453-datetime-in-php-mysql/#findComment-39016 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.