Jump to content

[SOLVED] > date format dd/mm/yy


Walker33

Recommended Posts

I'm trying to make an if statement dependant on the start date being greater than Jan 1, 2007.  If my db field format was yyyy/mm/dd , then the way I'm going about it works fine.  But format is mm/dd/yy, and I'm not getting the right result.  Do I need to convert to yyyy/mm/dd (and if so, any help would be appreciated) or is there a way to do a > or < check against format mm/dd/yy format?  Here's what I have:

 

$selected_radio = $_POST['user_type'];

 

// check table to see if they already exist as active user

$query = mysql_query("SELECT * FROM customer_details WHERE FirstName = '$InitFName' AND LastName = '$InitLName' AND Email = '$InitEmail' and status = 'active'");

$num = mysql_num_rows($query);

$result = mysql_fetch_assoc($query);

 

if($num>0 && $selected_radio=='reporter' && $result["Start_Date"] > '01/01/07')

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/156941-solved-date-format-ddmmyy/
Share on other sites

Thanks all, you steered me down the right path.  Pretty new to this and didn't know strtotime .  For anyone else in the future, I solved the issue by adding and changing:

 

$my_date = $result["Start_Date"];

$my_time = strtotime($my_date);

$datenew = date('Y-m-d',$my_time);

 

if($num>0 && $selected_radio=='reporter' && $datenew > '2007-01-01')

 

Great help, and greatly appreciated.

Thanks all, you steered me down the right path.  Pretty new to this and didn't know strtotime .  For anyone else in the future, I solved the issue by adding and changing:

 

$my_date = $result["Start_Date"];

$my_time = strtotime($my_date);

$datenew = date('Y-m-d',$my_time);

 

if($num>0 && $selected_radio=='reporter' && $datenew > '2007-01-01')

 

Great help, and greatly appreciated.

 

Good, but in the future please be sure to use


tags around code for proper formatting and syntax highlighting.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.