note 56222 added to function.date
| From: | MarcovanBeek at osu1 dot php dot net | Date: | Sat, 27 Aug 2005 17:50:45 +0000 |
| Subject: | note 56222 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-94267@lists.php.net to get a copy of this message | ||
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;
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56222
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56222&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56222&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56222&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56222&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56222&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56222&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56222&report=yes
Search -- http://master.php.net/manage/user-notes.php