PHP - inserting a date into the database results in wrong date format?
I have this query represented as a string (its shortened to make it easier to read):

    $query = 'INSERT INTO mytable (ke_voucher_date) VALUES (\'%s\')';

Now this is what I do next:

    $query = vsprintf($query, array_map('mysql_real_escape_string', $params));
    mysql_query($query);

$params is an array holding all values that should be saved, in this case (because its shortened) only the date in the format dd.mm.yyyy (21.04.2012). The result is 21.04.2026 for example. Whats wrong with the code, ideas? Maybe the %s?

Thanks!
        


PHP - inserting a date into the database results in wrong date format?
===

I have this query represented as a string (its shortened to make it easier to read):

    $query = 'INSERT INTO mytable (ke_voucher_date) VALUES (\'%s\')';

Now this is what I do next:

    $query = vsprintf($query, array_map('mysql_real_escape_string', $params));
    mysql_query($query);

$params is an array holding all values that should be saved, in this case (because its shortened) only the date in the format dd.mm.yyyy (21.04.2012). The result is 21.04.2026 for example. Whats wrong with the code, ideas? Maybe the %s?

Thanks!
        

