Here is the answer to my question of how to format a MySQL date or time field in PHP:
Dreamweaver recordset: row_signup_list
MySQL Date record: task_date
MySQL Time record: task_time_start
Thanks to google's search of the Dreamweaver newsgroup and a second night on the internet I got it working:
[php] <?php $date= $row_signup_list['task_date']; $date=explode("-",$date); echo"$date[1]-$date[2]-$date[0]"; ?> [/php]
(to make format: 10-18-2002)
And it also had the time!
[php] <?php $temptime = strtotime($row_signup_list['task_time_start']); $thetime = date("g:i a",$temptime); echo "$thetime"; ?> [/php]
(to make format: 11:04 am)
Hope this is of use to someone.
Thank you,
iolaire
--- old post --
Using Dreamweaver I'm trying to set up a simple website where someone
can sign up for a volunteer task. Right now I'm running against a wall
trying to re-format a date from a MySQL date field (0000-00-00) to
(12-31-2002. My Dreamweaver record-set is signup_list and my date
field is task_date.
It seems like I should be able to use some simple code to format it in
Month Day Year format. However, this is as close as I can get:
[php] <?php echo date('M-d-Y',$row_signup_list['task_date']); ?> [/php]
and that generates a date of Dec 31 1969 regardless of what is in the
database field.
Looking online it seems like the PHP date function is usually used to
calculate a future date form the current date or generate the current
date. Otherwise there are complex codes relating to the UNIX Timestamp
function.
Please can someone tell how to format a MySQL date via PHP?
Thank you,
iolaire
(If there is any easy way to add it to the select statment, that would
be fine.)
SELECT *
FROM tasks, event
WHERE event.event_id = tasks.task_event AND tasks.task_event = picktask
(picktask is a variable passed from the previous page)