0

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

4
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by johnsquibb
0

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!!!

0
<?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;
?>
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.