PHP Date Format

Discussion in 'PHP' started by nitestarz, Aug 30, 2012.

  1. #1
    I have a form where the date is displayed in UK format.

    When the date is submitted from the website and emailed to me I would like the date to be converted back so that it is a m/d/y format.

    Any ideas would be appreciated. Please let me know if you need more information.

    Thanks!
     
    nitestarz, Aug 30, 2012 IP
  2. jadexe

    jadexe Member

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    26
    #2
    You can use PHP's date() function to convert it.
     
    jadexe, Aug 30, 2012 IP
  3. nitestarz

    nitestarz Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    But how?

    My header sends information to thank you page as well as sends an email with the information contained in the form
     
    nitestarz, Aug 30, 2012 IP
  4. jadexe

    jadexe Member

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    26
    #4
    $usDate = date("m-d-Y", strtotime($ukDate));
     
    jadexe, Aug 30, 2012 IP
  5. kod0k

    kod0k Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #5
    $example = date("m/d/y");
    echo $example;
     
    kod0k, Aug 31, 2012 IP
  6. elitestar47

    elitestar47 Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    $example = date("m/d/y");
    echo $example;

    This is the right function for this.
     
    elitestar47, Sep 1, 2012 IP
  7. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #7
    If I might make a suggestion -- I'd suggest "j F Y" or "j M Y" -- you never have to mess with the order and it leaves zero confusion. Far, far easier than leaving them all numbers and constantly swapping back and forth to simply say "1 September 2012" or "1 Sep 2012" -- oh noes, it's a few more characters, not that. When it comes to European format vs. US format, turns it into a non-issue.

    Which of course, is why most western militaries uses "j F Y" on all official documents.
     
    deathshadow, Sep 1, 2012 IP
  8. kod0k

    kod0k Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #8
    yea, i always use that function :)
     
    kod0k, Sep 1, 2012 IP
  9. nitestarz

    nitestarz Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I don't think I properly explained myself, I apologize.

    The date is selected by the user, for example they may be submitting for a class on 24/9/2012.

    That is the date I need to format back to US, so when it is submitted into our db it matches up with the class date of 9/24/2012.

    Does that make sense?

    Thanks!
     
    nitestarz, Sep 4, 2012 IP
  10. DomainerHelper

    DomainerHelper Well-Known Member

    Messages:
    445
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    100
    #10
    DomainerHelper, Sep 4, 2012 IP
  11. lolpasslol

    lolpasslol Peon

    Messages:
    860
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #11
    If you can share the source code then it would be easier for me to say something about this and also i learn something.
     
    lolpasslol, Sep 4, 2012 IP
  12. DomainerHelper

    DomainerHelper Well-Known Member

    Messages:
    445
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    100
    #12
    Learn the way I did... books.
     
    DomainerHelper, Sep 5, 2012 IP