note 24009 modified in function.date by philip

From: Date: Sat, 26 Oct 2002 22:37:07 +0000
Subject: note 24009 modified in function.date by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-38608@lists.php.net to get a copy of this message
[Editors note: Using MySQL's date and time functions is a preferred method, i.e. UNIX_TIMESTAMP.] Converting mySQL timestamp to PHP timestamp to use in a date(); function call. Something small and simple. function make_time($datetime) { $yr = substr($datetime,0,4); $mon = substr($datetime,4,2); $day = substr($datetime,6,2); $hr = substr($datetime,8,2); $min = substr($datetime,10,2); $sec = substr($datetime,12,2); return mktime($hr,$min,$sec,$mon,$day,$yr); } --was-- Converting mySQL timestamp to PHP timestamp to use in a date(); function call. Something small and simple. function make_time($datetime) { // Converts mySQL timestamp to PHP timestamp // for use with date(); $yr = substr($datetime,0,4); $mon = substr($datetime,4,2); $day = substr($datetime,6,2); $hr = substr($datetime,8,2); $min = substr($datetime,10,2); $sec = substr($datetime,12,2); return mktime($hr,$min,$sec,$mon,$day,$yr); } http://www.php.net/manual/en/function.date.php

« previous php.notes (#38608) next »