-
PHP (
http://www.daniweb.com/forums/forum17.html)
| Morty222 | Mar 5th, 2008 10:54 pm | |
| Time Stamp Help I am using current_timestamp and it works great but when I output the data onto a php page it looks like this:
2008-03-05 18:05:44
Anyone know how I can make it look like this?
03-05-2008 18:05:44 |
| fert | Mar 6th, 2008 12:11 am | |
| Re: Time Stamp Help Use the date() function: http://php.net/date
$time = time();
$date = date('d-m-L H:i:s' , $time);
echo $date; // 03-05-2008 18:05:44 |
| ryan_vietnow | Mar 6th, 2008 12:16 am | |
| Re: Time Stamp Help Here,I made a function just for you using explode function:
//$var is your timestamp...
function x($var)
{
list($date,$time)=explode(" ", $var);
list($year,$month,$day)=explode("-",$date);
$newdate=$month."-".$day."-".$year." ".$time;
return $newdate;
}
Enjoy!!! |
| johnsquibb | Mar 6th, 2008 12:18 am | |
| Re: Time Stamp Help <?php
//old time
$old_time = '2008-03-05 18:05:44';
//convert to UNIX timestamp
$timestamp = strtotime($old_time);
//fetch new format
$new_time = date('m-d-Y H:i:s' , $timestamp);
//output new time
echo $new_time;
?> |
| johnsquibb | Mar 6th, 2008 12:29 am | |
| Re: Time Stamp Help Quote: Originally Posted by fert (Post 553354) Use the date() function: http://php.net/date
$time = time();
$date = date('d-m-L H:i:s' , $time);
echo $date; // 03-05-2008 18:05:44 | 'L' returns 1 if it is a leap year or 0 if it is not. Use 'Y' for 4-digit year. |
| All times are GMT -4. The time now is 2:41 am. | |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC