List Info

Thread: note 74687 added to function.date




note 74687 added to function.date
user name
2007-04-23 13:15:41
Ever had a DATETIME in a database and want to format it
using the date() function? Me too. Here you go.

<?

// format MySQL DateTime (YYYY-MM-DD hh:mm:ss) using date()

function datetime($syntax,$datetime) {
	$year = substr($datetime,0,4);
	$month = substr($datetime,5,2);
	$day = substr($datetime,8,2);
	$hour = substr($datetime,11,2);
	$min = substr($datetime,14,2);
	$sec = substr($datetime,17,2);
	
	return
date($syntax,mktime($hour,$min,$sec,$month,$day,$year));
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 74.132.11.223
----
Manual Page -- http:/
/www.php.net/manual/en/function.date.php
Edit        -- https://master
.php.net/note/edit/74687
Del: integrated  -- h
ttps://master.php.net/note/delete/74687/integrated
Del: useless     -- http
s://master.php.net/note/delete/74687/useless
Del: bad code    -- htt
ps://master.php.net/note/delete/74687/bad+code
Del: spam        -- https:/
/master.php.net/note/delete/74687/spam
Del: non-english -- 
https://master.php.net/note/delete/74687/non-english
Del: in docs     -- http
s://master.php.net/note/delete/74687/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/74687
Reject      -- https://mast
er.php.net/note/reject/74687
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )