SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jun 2002
    Location
    Umea Sweden
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Convert date-string yyyy-mm-dd to dd/mm

    I would like to have some help with this problem:

    My code selects a date from my database:

    $sqlquery = "SELECT ent_date FROM $table"; $result = mysql_query($sqlquery);

    This ent_date is in yyyy-mm-dd format. What I want to do is to print out ent_date in the dd/mm format.

    Example:
    2003-07-21 is to be printed like 21/7 (without the 07 if its possible)


    Anyone care to help me with this? Would really appreciate it...

  2. #2
    SitePoint Addict nodding dino's Avatar
    Join Date
    May 2003
    Location
    London
    Posts
    217
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try using date_format in the sql statement...

    for example select date_format(ent_date, "%d"/"%m") as newdate from %table

    where newdate is a variable that hold the formatted date...there are other options you can use in the date_format param, but this should probably do what your after...

    GOOD LUCK!

  3. #3
    SitePoint Addict nodding dino's Avatar
    Join Date
    May 2003
    Location
    London
    Posts
    217
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oops - $table!!!


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
  •