Re: [PHP4BETA] Silly question re formatting dates from a database...

From: Date: Tue, 14 Mar 2000 23:51:39 +0000
Subject: Re: [PHP4BETA] Silly question re formatting dates from a database...
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-12114@lists.php.net to get a copy of this message
On Tue, 14 Mar 2000, Ryan Robertson wrote: > Ok, so this is a really dumb question. Are there any functions to format a > date from a database? I can't find anything obvious in either the string > functions or in the date/time functions. You can: 1. Make the database return the date in a format you want (check out, for example, the date/time functions in the MySQL manual). 2. Use a function similar to this to break apart the date into a Unix timestamp. /* convert YYYY-MM-DD HH:mm:SS to seconds since epoch */ function seconds_since_epoch ($date) { list($year,$month,$day,$hour,$minute,$second) = split('[- :]', $date); $seconds_since_epoch = mktime($hour,$minute,$second,$month,$day,$year); if ($seconds_since_epoch >= 0) { return $seconds_since_epoch; } return false; } -adam -- / adam maccabee trachtenberg | visit college life online \ \ adam@student.net | http://www.student.com /

« previous php.version4 (#12114) next »