Decode and Encode Date from variables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marius III

    Decode and Encode Date from variables

    Hi there friends,

    I want to encode a date in PHP5.

    I have 3 variables for ex:

    $day = 20 (integer)
    $month = 10 (integer)
    $year = 2005 (integer)

    These 3 variables must be converted to a valid date for ex:

    $paymentdate = EncodeDate($yea r, $month, $day);

    Now I want to save the $paymentdate variable in a MySQL Date field.

    BTW: I am looking for a similar function than the example "EncodeDate ()".
    I my primary programming language there is a encodedate() function.

    Please advice,

    Thank you in advance!!!


  • Janwillem Borleffs

    #2
    Re: Decode and Encode Date from variables

    Marius III wrote:[color=blue]
    > BTW: I am looking for a similar function than the example
    > "EncodeDate ()". I my primary programming language there is a
    > encodedate() function.
    >[/color]

    Parse about any English textual datetime description into a Unix timestamp



    JW



    Comment

    • R. Rajesh Jeba Anbiah

      #3
      Re: Decode and Encode Date from variables

      Marius III wrote:[color=blue]
      > I want to encode a date in PHP5.
      >
      > I have 3 variables for ex:
      >
      > $day = 20 (integer)
      > $month = 10 (integer)
      > $year = 2005 (integer)
      >
      > These 3 variables must be converted to a valid date for ex:
      >
      > $paymentdate = EncodeDate($yea r, $month, $day);[/color]

      Simply, sprintf() <http://in.php.net/sprintf> can be used like
      sprintf("%04d-%02d-%02d", $year, $month, $day). For, more date
      operations, you may use <http://www.phpinsider. com/php/code/Date_Calc/>

      --
      <?php echo 'Just another PHP saint'; ?>
      Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

      Comment

      • Janwillem Borleffs

        #4
        Re: Decode and Encode Date from variables

        R. Rajesh Jeba Anbiah wrote:[color=blue]
        > Simply, sprintf() <http://in.php.net/sprintf> can be used like
        > sprintf("%04d-%02d-%02d", $year, $month, $day). For, more date
        > operations, you may use
        > http://www.phpinsider.com/php/code/Date_Calc/
        >[/color]

        If I'm not mistaking, the language referenced to is delphi of which the
        encodedate() function returns a timestamp, not a formatted string.


        JW



        Comment

        • R. Rajesh Jeba Anbiah

          #5
          |OT| Re: Decode and Encode Date from variables

          Janwillem Borleffs wrote:
          <snip>[color=blue]
          > If I'm not mistaking, the language referenced to is delphi of which the
          > encodedate() function returns a timestamp, not a formatted string.[/color]

          Oh, Thanks. Sorry for confusing OP.

          --
          <?php echo 'Just another PHP saint'; ?>
          Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

          Comment

          Working...