Hi all,
I have got a date session vailable on my page and I write out the date in the following way :
<?php echo format_date($_SESSION['booking']['from']); ?> and it returns Wed 17 December 2008.
I was wondering if there is a way to format it so that it would come out like Wed 17th December 2008 ?
Many thanks
Formatting php S suffix for date
Moderator: General Moderators
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Formatting php S suffix for date
take a look at http://uk2.php.net/date
Write it like:
Write it like:
Code: Select all
date("chosen_format", strtotime($_SESSION['booking']['from']));Re: Formatting php S suffix for date
Hi Many thanks for your reply.
When I changed the code to<?php echo date("S", strtotime($_SESSION['booking']['from'])); ?> , it only came out as th. I am not sure where it when wrong...
Regards,
When I changed the code to<?php echo date("S", strtotime($_SESSION['booking']['from'])); ?> , it only came out as th. I am not sure where it when wrong...
Regards,
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Formatting php S suffix for date
You have to declare the full format. "S" will only output "th" or "rd" etc...
Use the link i sent you to find out different formats to use e.g. If i wanted to format a date as "DD-MM-YYYY" i would write it like this:
Use the link i sent you to find out different formats to use e.g. If i wanted to format a date as "DD-MM-YYYY" i would write it like this:
Code: Select all
echo date("d-m-Y", strtotime($_SESSION['booking']['from']));