American Date conversion

Discussion in 'PHP' started by DarrenC, May 21, 2007.

  1. #1
    Before I start I'm clueless when it comes to PHP.

    In my database it is generating an American date format mm/dd/yyyy

    I want to make this into a UK date format dd/mm/yyyy

    Is there a php code to convert this?

    :rolleyes:
     
    DarrenC, May 21, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    function ukdate($usdate)
    {
    	return date('d/m/Y', strtotime($usdate));
    }
    
    // Outputs: 28/12/2006
    echo ukdate('12/28/2006');
    
    
    PHP:
     
    nico_swd, May 21, 2007 IP
    DarrenC likes this.
  3. coderbari

    coderbari Well-Known Member

    Messages:
    3,168
    Likes Received:
    193
    Best Answers:
    0
    Trophy Points:
    135
    #3
    nico's code is perfect :)
     
    coderbari, May 21, 2007 IP
    DarrenC likes this.
  4. DarrenC

    DarrenC Peon

    Messages:
    3,386
    Likes Received:
    154
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Cheers Nico!!

    I'll try that out tonight.

    Another question...

    I have a field called 'holiday type' the data in the field is 'Golf' but when I want to display it on the php page I want it to be 'golf' i.e. no capital G. Is there a way around this?

    Darren
     
    DarrenC, May 23, 2007 IP
  5. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #5
    nico_swd, May 24, 2007 IP