Page 1 of 1

Date & Time Format

Posted: Thu May 06, 2010 11:26 am
by nitediver
First,
Does, date with timestamp type in mysql can be format when selected/display?
2010-05-06 19:49:33 >> 19:49:33 05-06-2010 [5-May-2010]

Second,
These code generating date & time like this: 6-5-2010 20:23:45.
I want to make it like this: 06-05-2010 20:23:45.
How to put "0" for number 1 to 9, since it using loop?

Code: Select all

<?
function fdate(){
//Date
echo "<select name=\"day\">";
for($d=1; $d<32; $d++){
echo ("<option>$d</option>");
}
echo "</select>";

//Month
echo "<select name=\"month\">";
for($m=1; $m<13; $m++){
echo ("<option>$m</option>");
}
echo "</select>";

//Year
$d = date(Y);
$b = date(Y)-2;
echo "<select name=\"year\">";
for($d; $d>$b; $d--){
echo ("<option>$d</option>");
}
echo "</select>";
}
?>

Re: Date & Time Format

Posted: Thu May 06, 2010 12:11 pm
by AbraCadaver

Re: Date & Time Format

Posted: Fri May 07, 2010 9:57 am
by nitediver
Thanks, after doing search I found these.

http://dev.mysql.com/doc/refman/5.1/en/datetime.html

MySQL does not accept timestamp values that include a zero in the day or month column or values that are not a valid date.

What does it mean, is it mean I can't change 6-5-2010 20:23:45 into 06-05-2010 20:23:45 ?

Re: Date & Time Format

Posted: Fri May 07, 2010 10:30 am
by AbraCadaver
nitediver wrote:Thanks, after doing search I found these.

http://dev.mysql.com/doc/refman/5.1/en/datetime.html

MySQL does not accept timestamp values that include a zero in the day or month column or values that are not a valid date.

What does it mean, is it mean I can't change 6-5-2010 20:23:45 into 06-05-2010 20:23:45 ?
No, it means you can't have 00-05-2010 or 06-00-2010.