RE: [PHP] Formatting a MYSQL time

From: Date: Thu, 07 Feb 2002 19:42:52 +0000
Subject: RE: [PHP] Formatting a MYSQL time
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-83896@lists.php.net to get a copy of this message
On Thu, 2002-02-07 at 10:47, Kevin Stone wrote: > Unless the $eventdate coming being pulled from your database a bonified > Unix timestamp the date() function will not work. > > I don't like MySQL functions so I've always used $timestamp = mktime() > to create the timestamp. Then plug that value into a field defined as > INT(14). Use $eventdate = date("g:i a", $timestamp) to convert the > timestamp into the desired English format. > > The mktime() function can also be used to convert from English time back > into a timestamp.. but it has kind of a weird format. It takes six > parameters and if you choose to use them they are all required. Minor correction: http://www.php.net/mktime Arguments may be left out in order from right to left; any arguments thus omitted will be set to the current value according to the local date and time. Torben > $timestamp = mktime($hour, $min, $sec, $month, $day, $year); > > Hope this helps some. > > -- > Kevin Stone > Kevin@helpelf.com > www.helpelf.com -- Torben Wilson <torben@php.net> http://www.thebuttlesschaps.com http://www.hybrid17.com http://www.inflatableeye.com +1.604.709.0506

« previous php.general (#83896) next »