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

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

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

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.