Ein Hazard Ein Hazard - 7 months ago 12
SQL Question

get datetime in database and show it in 3 separately field dreamweaver [ year, month, day ]

iam using xampp for database and dreamweaver for website.

Field 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 textfield 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 id and name from database and show it by using php echo

but how do i show the birthday separately in each select/list year, month and day ???

Answer

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! :)

Comments