Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: php date format

  1. #1
    New Coder
    Join Date
    Aug 2004
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php date format

    Hello,

    Please any help about that.
    Here is the code :
    Code:
    for($m = 0;$m <= 0; $m++)
    {
    $now = date ("Y-m-d", mktime (0,0,0,date("m"),date("d")+$m,date("Y")));
    echo "<input type=\"hidden\" name=\"open_date\" value=\"" . $now . "\">";
    }
    It inserts the actual date in YYYY-MM-DD.
    The field "open_date" in the MYSQL table is type "date".
    Could you please give the exact modification to give to this code to have DD-MM-YYYY format cause for the moment always 0000-00-00 result...

    Thanks a lot,

    seb

  • #2
    Regular Coder
    Join Date
    Nov 2010
    Location
    Oregon
    Posts
    243
    Thanks
    23
    Thanked 10 Times in 10 Posts
    Quote Originally Posted by santille View Post
    Hello,

    Please any help about that.
    Here is the code :
    Code:
    for($m = 0;$m <= 0; $m++)
    {
    $now = date ("Y-m-d", mktime (0,0,0,date("m"),date("d")+$m,date("Y")));
    echo "<input type=\"hidden\" name=\"open_date\" value=\"" . $now . "\">";
    }
    It inserts the actual date in YYYY-MM-DD.
    The field "open_date" in the MYSQL table is type "date".
    Could you please give the exact modification to give to this code to have DD-MM-YYYY format cause for the moment always 0000-00-00 result...

    Thanks a lot,

    seb
    just change this to "d-m-y"

  • #3
    New Coder
    Join Date
    Aug 2004
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for your answer.
    No way with this task : that's the first thing I tried.

  • #4
    Regular Coder
    Join Date
    Nov 2010
    Location
    Oregon
    Posts
    243
    Thanks
    23
    Thanked 10 Times in 10 Posts
    I just tyied it the output was 09-12-2010 instead of 2010-12-09

    Code:
    <?php        
    for($m = 0;$m <= 0; $m++)
    {
    $now = date ("d-m-Y", mktime (0,0,0,date("m"),date("d")+$m,date("Y")));
    echo "<input type='text' name='open_date' value='$now'>";
    } 
    ?>

  • #5
    New Coder
    Join Date
    Aug 2004
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Could you tell me exactly how did you test to obtain this result?
    It does not return that for me...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •