View Single Post
Old 12-11-2012, 07:29 PM   PM User | #7
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,650
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
This is fine:
PHP Code:
$N_pub_date     strtotime("{$row['pub_date']}"); 
$N_pub_date     date("m/d/y"$N_pub_date); 
So long as $row['pub_date'] represents a valid datetime string in SQL and strtotime is available (which it has been since like, 4.2 or something like that). So if I do this:
PHP Code:
$row = array('pub_date' => '2009-10-04 22:23:00');
$N_pub_date     strtotime("{$row['pub_date']}"); 
$N_pub_date     date("m/d/y"$N_pub_date);
printf('Date: %s'$N_pub_date); 
I get this:
Code:
Date: 10/04/09
As for SQL, although I'd suggest querying for each property separately, you can mix and match wildcards with explicits. SELECT *, DATE_FORMAT(pub_date, '%m/%d/%Y') AS formattedDate FROM. . . is fine.
Fou-Lu is offline   Reply With Quote