String to time in php
I am making a web application that connects to user's Dropbox account. When i retrieve metadata of files and folders, Dropbox returns corresponding modified dates o开发者_如何学编程n following format:
"Sat, 21 Aug 2010 22:31:20 +0000"
How can i convert this to following format?
21/08/2010 22:31
Any help will be much appreciated.
Many questions on formatting dates, you should find what you are looking for by searching.
Here a quicky:
echo date("d/m/Y H:i", strtotime($sOriginalformat));
You could use the function strtotime()
. Have a look at the Manual.
strtotime("Sat, 21 Aug 2010 22:31:20 +0000");
You can use strtotime
. If you might ever want to do more complex things, have a look at the DateTime
class. It is powerful and intuitive -- I think it's more transparent than mucking around with the timestamp yourself.
$dt = new DateTime($sOriginalFormat);
$sNewFormat = $dt->format("d/m/Y H:i");
精彩评论