86Stang Posted May 20, 2008 Share Posted May 20, 2008 I've got a timestamp that shows the last updated like this: 2008-05-07 10:36:35 The problem is that I'd like it to NOT show the time, just the date. How can I make that happen with this: $row[updated] ?? Link to comment https://forums.phpfreaks.com/topic/106415-format-the-look-of-a-timestamp/ Share on other sites More sharing options...
The Little Guy Posted May 20, 2008 Share Posted May 20, 2008 Like this: $t = strtotime($row[updated]); echo date("m/d/Y g:i:s",$t); returns: 05/07/2008 10:36:35 modify the date format for a different output Link to comment https://forums.phpfreaks.com/topic/106415-format-the-look-of-a-timestamp/#findComment-545464 Share on other sites More sharing options...
mmarif4u Posted May 20, 2008 Share Posted May 20, 2008 OR,if u simply want to show date. $date=date('m-d-Y',strtotime($row[updated])); echo $date; will return: 07-05-2008 Link to comment https://forums.phpfreaks.com/topic/106415-format-the-look-of-a-timestamp/#findComment-545465 Share on other sites More sharing options...
The Little Guy Posted May 20, 2008 Share Posted May 20, 2008 OR,if u simply want to show date. $date=date('m-d-Y',strtotime($row[updated])); echo $date; will return: 07-05-2008 I believe it will be 05-07-2008, because I think the timestamp is formatted like so: YYYY-MM-DD HH:MM:SS Link to comment https://forums.phpfreaks.com/topic/106415-format-the-look-of-a-timestamp/#findComment-545478 Share on other sites More sharing options...
mmarif4u Posted May 20, 2008 Share Posted May 20, 2008 Oh,sori. Should like this for that which i mention: date('d-m-Y') Link to comment https://forums.phpfreaks.com/topic/106415-format-the-look-of-a-timestamp/#findComment-545479 Share on other sites More sharing options...
PFMaBiSmAd Posted May 20, 2008 Share Posted May 20, 2008 To just show or use the date part of a DATETIME or mysql timestamp, use the mysql DATE() function - DATE(expr) Extracts the date part of the date or datetime expression expr. mysql> SELECT DATE('2003-12-31 01:02:03'); -> '2003-12-31' To format a DATE, DATETIME or mysql Timestamp, use the mysql DATE_FORMAT() function - DATE_FORMAT(date,format) Formats the date value according to the format string. The following specifiers may be used in the format string. The “%” character is required before format specifier characters. ... see the table in the mysql manual for complete information... Link to comment https://forums.phpfreaks.com/topic/106415-format-the-look-of-a-timestamp/#findComment-545574 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.