SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    http://TheICE.co.uk/ The Eerie Network's Avatar
    Join Date
    Apr 2001
    Location
    London in the UK.
    Posts
    293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    reversing the date

    I'm using dates in the format of yyyy-mm-dd to order the queries on my table.
    What I wanted to know is if their is a way of altering the day that date is displayed so that rather than yyyy-mm-dd I can have dd mm yyyy

    any ideas?
    Daniel Hollands
    New: My Webcam <-- Come and watch me doing what I do
    TheICE.co.uk <-- New sites for the best in UK lifestyle and Competitions.
    The ofDan.Network Forums <-- Come and join in the fun.

  2. #2
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is a function I use to change the CURDATE() date format for display...

    Code:
    function date_format($date) {
      $array = split("-", $date);
      $array[1] = ($array[1] != 10) ? str_replace("0", "", $array[1]) : $array[1];
      $array[2] = (($array[2] != 10) && ($array[2] != 20) && ($array[2] != 30)) ? str_replace("0", "", $array[2]) : $array[2];
      $date = "$array[1]-$array[2]-$array[0]";
      return $date;
    }
    Then, just use something like this to format it:

    $date = date_format($date);

  3. #3
    http://TheICE.co.uk/ The Eerie Network's Avatar
    Join Date
    Apr 2001
    Location
    London in the UK.
    Posts
    293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you, but I need the date to be in english format:
    dd/mm/yyyy, is this possable?
    Daniel Hollands
    New: My Webcam <-- Come and watch me doing what I do
    TheICE.co.uk <-- New sites for the best in UK lifestyle and Competitions.
    The ofDan.Network Forums <-- Come and join in the fun.

  4. #4
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep...

    Code:
    function date_format($date) {
      $array = split("-", $date);
      $array[1] = ($array[1] != 10) ? str_replace("0", "", $array[1]) : $array[1];
      $array[2] = (($array[2] != 10) && ($array[2] != 20) && ($array[2] != 30)) ? str_replace("0", "", $array[2]) : $array[2];
      $date = "$array[2]-$array[1]-$array[0]";
      return $date;
    }
    That should do it.

  5. #5
    http://TheICE.co.uk/ The Eerie Network's Avatar
    Join Date
    Apr 2001
    Location
    London in the UK.
    Posts
    293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers dude
    Daniel Hollands
    New: My Webcam <-- Come and watch me doing what I do
    TheICE.co.uk <-- New sites for the best in UK lifestyle and Competitions.
    The ofDan.Network Forums <-- Come and join in the fun.


Bookmarks

Posting Permissions

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