Page 1 of 1

Date Format and passing a value to it.

Posted: Fri Aug 22, 2008 10:44 am
by Addos
Hi,
I need to display a date format as 12th August 2008 but am having problems applying this.

This will give me the present time echo date('jS F Y'); will do this but I need to apply this using the following variable.
($date = ‘2008-08-12’);

I have played with an array using

Code: Select all

$dtt = explode('-', $date);
$dtt = $dtt[2]. '-'. $dtt[1] .'-' .$dtt[0];
      echo $dtt;
which gives me 12-08-2008 ie the correct European order but I’m stuck trying to pass $date or $dtt to date('jS F Y'); tried date('$date','jS F Y');?> but this is not working.
Any help would be great

Re: Date Format and passing a value to it.

Posted: Fri Aug 22, 2008 11:00 am
by ghurtado
date() can take an optional second argument, a timestamp.

Try this to get your timestamp first:

http://us2.php.net/manual/en/function.strtotime.php