Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.