Ein Hazard Ein Hazard - 4 months ago 10x
MySQL Question

Get datetime in a database and show it in 3 separate fields in dreamweaver [ year, month, day ]

I am using xampp for my database and dreamweaver for my website.

Fields in database :

field 1 = id : int, primarykey and auto increment

field 2 = name : text

field 3 = birthday : datetime

example data :

id: 01

name : jhon

birthday : 2000-06-01

In dreamweaver I have 2 textfields and 3 select/list :

One textfield for id, one textfield for name, one select/list for year in birthday, one for month and one for day.

I can get the id and name from the database and show it by using php echo.

How do I show the birthday separately in each select/list year, month and day ?


When you retrieve the datetime variable, you'll have it in a string similar to this:

$datetime = '2000-06-01';

If you have already gotten to that point, then do the following:

list($year, $month, $day) = explode("-", $datetime);

echo "year = ".$year."<br>";//year = 2000
echo "month = ".$month."<br>";//month = 06
echo "day = ".$day."<br>";//day = 01

Hope I could help! :)