Jump to content

The Zero in the day and month will not post


phpretard

Recommended Posts

I am trying to compare values and if the month is not of 2 digits then the comparison goes wrong.

 

Here is some hacked crap that doesn't work.


if (strlen($_POST['m'] <= 1)){$month = "0".$_POST['m'];}else{$month = $_POST['m'];}
if (strlen($_POST['d'] <= 1)){$day = "0".$_POST['d'];}else{$day = $_POST['d'];}

<form>

function GetDays(){
    $Listd = '<select name="d">';
if (isset($_POST['d'])){$Listd .='<option value="'.$_POST['d'].'">'.$_POST['d'].'</option>';}
    for ($x = 1; $x <= date('d'); $x++)
$Listd .= '<option value="'.$x.'">'.$x.'</option>';
    $Listd .= '</select>';
    return $Listd;
}

function GetMonths(){
    $Listm = '<select name="m">';
if (isset($_POST['m'])){$Listm .='<option value="'.$_POST['m'].'">'.$_POST['m'].'</option>';}
    for ($x = 1; $x <= date('m'); $x++)
$Listm .= '<option value="'.$x.'">'.$x.'</option>';
    $Listm .= '</select>';
    return $Listm;
}

 

Here is what I am comparing:

Now:          201012141292327875

Submitted: 201110101292353200 // 2 digit month/day

 

Now:          201012141292327984

Submitted: 2011991292353200 // not 2 digits month/day

 

2 hours is enough for me...can someone shed some light on this for me please?

Link to comment
Share on other sites

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.