sorry i'm newbie in date/time in php, i would like to ask if this is correct script or not,if not can u help me improving this script.

<?php

$date1 = date('m-d-Y H:i:s a');
$date2 = "09-17-2011 11:51:21 am";

if($date1>=$date2){
echo "bad";
}else{
echo "good";
}
but when i change the year of $date2 to 2010 so it means the output should be bad because the $date1>=$date but when i try to run the script output still the same which is "good".someone help me should be appreciated..n thanks n advance.
?>

Nope, that's not gonna work. You're now comparing strings, not dates. Try something like this:

$date1 = time();
$date2 = date_create('2011-09-17 11:51:21');
...
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.