datetime format

Discussion in 'PHP' started by playwright, Jul 29, 2010.

  1. #1
    Hello!! i want to save datetimes into a mysql database. Their format is dd-mm-yy hh:mm. I think mysql format for datetime is yy-mm-dd hh:mm..How can i convert them??
     
    playwright, Jul 29, 2010 IP
  2. Deacalion

    Deacalion Peon

    Messages:
    438
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    <?php
        // MySQL format
        $format_1 = date('Y-m-d H:i:s');
        
        // Convert to new format
        $format_2 = date('d-m-Y H:i:s', strtotime($format_1));
        
        // Convert back to MySQL format
        $format_3 = date('Y-m-d H:i:s', strtotime($format_2));
    ?>
    
    PHP:
     
    Deacalion, Jul 29, 2010 IP