The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 7 of 7

Thread: date format changing...

  1. #1
    146
    posts
    Registered User

    date format changing...

    Hi all,

    I'm having a really huge problem formating the date of my MySQL database field. the date field shows by default yyyy-mm-dd and I need it to show mm.dd.yyyy can anyone explain to me how can I do this?

    thanks for the attention

  2. #2
    I have a common functions library with these functions:
    function make_normal_date( $date )
    {
    $date = date("d-m-Y",mktime(0, 0, 0, (int)substr( $date , 5, 2), (int)substr( $date , 8, 2), (int)substr( $date , 0, 4) ));
    return $date;
    }

    function make_sql_date( $date )
    {
    $date = date("Y-m-d",mktime(0, 0, 0, (int)substr( $date , 3, 2), (int)substr( $date , 0, 2), (int)substr( $date , 6, 4) ));
    return $date;
    }
    the world is getting more complex because people need simple solutions

  3. #3

  4. #4
    146
    posts
    Registered User
    I'm trying but always get error message like this...
    Error

    SQL query:
    DATE_FORMAT( NOW( ) , '%c.%e.%Y' )
    MySQL said:
    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DATE_FORMAT(NOW(),'%c.%e.%Y')' at line 1

  5. #5
    146
    posts
    Registered User
    Quote Originally Posted by borrob View Post
    I have a common functions library with these functions:
    function make_normal_date( $date )
    {
    $date = date("d-m-Y",mktime(0, 0, 0, (int)substr( $date , 5, 2), (int)substr( $date , 8, 2), (int)substr( $date , 0, 4) ));
    return $date;
    }

    function make_sql_date( $date )
    {
    $date = date("Y-m-d",mktime(0, 0, 0, (int)substr( $date , 3, 2), (int)substr( $date , 0, 2), (int)substr( $date , 6, 4) ));
    return $date;
    }
    where do I place that in my code? on the head? body? thanks...

  6. #6
    146
    posts
    Registered User
    I made a screenshot of what I'm seening on my MySQL admin...
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	screenshotMamp.jpg 
Views:	15 
Size:	68.7 KB 
ID:	50510  

  7. #7
    This works for me...
    Code:
    SELECT DATE_FORMAT(date, '%c.%e.%Y')
     FROM `tablename`;
     // Output sample 1.20.2009

    where do I place that in my code? on the head? body? thanks...
    Could be anywhere. Just make sure it's within PHP tags.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012