•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 427,196 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,191 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 423 | Replies: 4
![]() |
Use the date() function: http://php.net/date
php Syntax (Toggle Plain Text)
$time = time(); $date = date('d-m-L H:i:s' , $time); echo $date; // 03-05-2008 18:05:44
•
•
Join Date: Aug 2007
Location: Cavite,Philippines
Posts: 508
Reputation:
Rep Power: 3
Solved Threads: 68
Here,I made a function just for you using explode function:
Enjoy!!!
php Syntax (Toggle Plain Text)
//$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!!!
"death is the cure of all diseases..."
http://ryantetek.wordpress.com
http://ryantetek.wordpress.com
•
•
Join Date: Nov 2007
Location: Las Vegas, Nevada
Posts: 83
Reputation:
Rep Power: 1
Solved Threads: 14
php Syntax (Toggle Plain Text)
<?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; ?>
The End
•
•
Join Date: Nov 2007
Location: Las Vegas, Nevada
Posts: 83
Reputation:
Rep Power: 1
Solved Threads: 14
•
•
•
•
Use the date() function: http://php.net/date
php Syntax (Toggle Plain Text)
$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.
The End
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- I just need TIME not Date. (MS SQL)
- date and time in file name (VB.NET)
- Convert time stamp to date using php (PHP)
- File with date + time (Python)
- Perl- How to call an event after a time delay (Perl)
- Need real time in XP (Visual Basic 4 / 5 / 6)
- Recording time stamp (PHP)
- help with clean win2000 install (Windows NT / 2000 / XP / 2003)
Other Threads in the PHP Forum
- Previous Thread: Choosing Symfony , Zend Framework, CakePHP
- Next Thread: PHPEclipse installation


Linear Mode