1

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 on 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.

Prashant
  • 7,340
  • 2
  • 25
  • 24

4 Answers4

5

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));
Wesley van Opdorp
  • 14,888
  • 4
  • 41
  • 59
1

You could use the function strtotime(). Have a look at the Manual.

Michiel Pater
  • 22,377
  • 5
  • 43
  • 57
1
strtotime("Sat, 21 Aug 2010 22:31:20 +0000");
Arun David
  • 2,714
  • 3
  • 18
  • 18
  • Thanks. But that was what I was doing. But I was getting 1306315565 as a result. Doesnt make any sense to me. – Prashant May 25 '11 at 14:41
  • @Prashant That's a UNIX timestamp. `strtotime` converts the time into an integer that represents the time. `date` can then interpret this value and format it as you wish. – lonesomeday May 25 '11 at 14:44
  • date("d/m/Y H:i",strtotime("Sat, 21 Aug 2010 22:31:20 +0000")); – Arun David May 25 '11 at 14:47
1

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");
lonesomeday
  • 233,373
  • 50
  • 316
  • 318