Creating Date Strings with PHP

When working with dates in php, it is easy to convert date strings when it outputs like 2010-01-24. You can convert that to almost anything you want, like January 1, 2010 or Jan 1/10.

Here is a simple method to create a date which can be inserted into a mySQL database. Alternatively, you can convert the string for output.

$year="1983";
$month="02";
$day="14";
$mydate = $year."-".$month."-".$day;
$mydate = date("Y-m-d", strtotime($mydate));

echo $mydate; //prints 1983-02-14