Web Analytics Made Easy -
StatCounter Converting to date type - CodingForum

Announcement

Collapse
No announcement yet.

Converting to date type

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Converting to date type

    Hi

    I have 3 dropdown menus for the date. One for the day, one for the month
    and one for the year. I am passing these as variables by using:

    PHP Code:

    $fday 
    $_POST["fromdate"]["mday"];
    $fmonth $_POST["fromdate"]["mon"];
    $fyear $_POST["fromdate"]["year"];

    $tday $_POST["todate"]["mday"];
    $tmonth $_POST["todate"]["mon"];
    $tyear $_POST["todate"]["year"]; 
    however, these are strings. I want to be able to make

    $fday and $fmonth and $fyear

    into a date type and then be able to
    make date comparisons with


    $tday and $tmonth and $tyear

    Is there a way that I can do this. The way I have tried is by casting the 3
    variables into int. And then concatenating them. But I am getting problems
    with it. There must be an easier way.

    Can anyone help me please?

  • #2
    I think you'd want to use the strtotime() function:
    http://ca3.php.net/manual/en/function.strtotime.php

    Hope that helps,
    Sadiq.

    Comment


    • #3
      actually, mktime would be just as good for this purpose:

      http://www.php.net/mktime
      "To be successful in IT you don't need to know everything - just where to find it in under 30 seconds"

      (Me Me Me Me Me Me Me Me Me)

      Comment

      Working...
      X