Jump to content


Photo

Format a date


  • Please log in to reply
2 replies to this topic

#1 Cep

Cep
  • Members
  • PipPipPip
  • Advanced Member
  • 539 posts
  • LocationOn a boat in the middle of nowhere

Posted 03 October 2006 - 11:00 AM

Hello, I am pulling a date field from an Access database and displaying it within a text box on my form.

The format the information is currently in is, 2005-11-07 00:00:00.

I need to display this date as 07/11/2005 (D M Y)

I have looked at the strftime function and it doesnt appear to work, I just keep getting a different combination of 01/01/1970.

How can I change this so that it displays correctly?


Thanks Cep

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 03 October 2006 - 11:02 AM

Use a combination of strtotime() and date():
<?php
$date_str = '2005-11-07 00:00:00';
echo date('d/m/Y',strtotime($date_str));
?>

Ken

#3 Cep

Cep
  • Members
  • PipPipPip
  • Advanced Member
  • 539 posts
  • LocationOn a boat in the middle of nowhere

Posted 03 October 2006 - 11:11 AM

Aha! I was using the wrong format function then, needed strtotime. Thanks Ken!
Thanks Cep




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users