PDA

View Full Version : date format


puja
04-25-2006, 01:03 PM
hi
im using mysql with php and mysql seems to store the date in the format 0000-00-00.
so that is the year and then the month and then the date??

is there anyway i can change that so that it can b in the format dd/mm/yyyy?

thanks

Masterslave
04-25-2006, 01:19 PM
function formatDate($date)
{
$timestamp = strtotime($date);
echo date('d-m-y', $timestamp);
}

http://nl3.php.net/function.date

eg:

formatDate($row['timestamp']);

puja
04-25-2006, 01:27 PM
ok thankyou
i want to use it to store like a booking start or end date and not today's date.
so do i put it on each page where i use those dates and format them as $date?
and will they then be stored in that format in my mysql tables aswell?

guelphdad
04-25-2006, 02:30 PM
Store your date in mysql as yyyy-mm-dd. Use the mysql date_format function to display your date in any way you wish.

puja
04-25-2006, 04:29 PM
thanks for your help
i was looking at your code for the room reservations.
i am trying to do something similar for holiday accommodation booking
wud the jist of the code therefore be the same?

guelphdad
04-25-2006, 06:20 PM
Yes, basically what you want to do for a booking is look at your start and end dates. If all of them start and end before OR after the dates you are looking for then the dates you want are available.