note 56222 deleted from function.date by mazzanet

From: Date: Sat, 27 Aug 2005 21:48:21 +0000
Subject: note 56222 deleted from function.date by mazzanet
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-94277@lists.php.net to get a copy of this message
Note Submitter: Marco van Beek ---- Here's a small function that allows you to take a MySQL timestamp(14) and convert it into a unix timestamp that can be formatted with date(). As MySQL can be left to automatically update the timestamp record, it is a nice way of giving a user a "Last Changed" line: <?PHP Function UseMySQLTimeStamp ( $TimeStamp ) { # Extract the data $Year = substr($TimeStamp,0,4); $Month = substr($TimeStamp,4,2); $Day = substr($TimeStamp,6,2); $Hour = substr($TimeStamp,8,2); $Minute = substr($TimeStamp,10,2); $Seconds = substr($TimeStamp,12,2); # Convert it to Unix format $UnixTime = mktime($Hour,$Minute,$Second,$Month,$Day,$Year); # Set the return Value for the Function return $UnixTime; } ?>

« previous php.notes (#94277) next »