Version: 1.0
Type: Function
Category: Calendars/Dates
License: GNU General Public License
Description: Two basic functions to convert a mySQL date to a UNIX timestamp and back.
//date_to timestamp accepts a date as parameter. In mySQLformat: yyyy-mm-dd (eg. 2001-03-16) //edit the delimiter to your convenience. //returns $timestamp; the timestamp associated with the input. function date_to_timestamp ($date) { $split_date = split ('-', $date); $timestamp = gmmktime (0, 0, 0, $split_date[1], $split_date[2], $split_date[0]); return $timestamp; } //timestamp_to_date accepts a timestamp as parameter. //returns $date. In mySQLformat; yyyy-mm-dd (eg. 2001-03-16) function timestamp_to_date ($timestamp) { $date = date ("Y-m-d" , $timestamp); return $date; }