Date Format and passing a value to it.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

Date Format and passing a value to it.

Post 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
User avatar
ghurtado
Forum Contributor
Posts: 334
Joined: Wed Jul 23, 2008 12:19 pm

Re: Date Format and passing a value to it.

Post 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
Post Reply