This question already has an answer here:
Hello i am trying to convert this date.
01. 06. 2015
Into mysql format, so i can insert it into database.
I tried this code, and other ombination with date and date format function.
`$mysqldate = date( 'Y-m-d H:i:s', strtotime($datefrom));`
but i get result
1.1.1970
Is it possible to do this with some date function, or i must use regex for resolving this problem. Maybe dateformat function?
</div>
Use this.. works fine
$datefrom = "01. 06. 2015";
$datefrom = str_replace( ". ", "-", $datefrom);
$mysqldate = date( 'Y-m-d H:i:s', strtotime($datefrom));
you need to clean your dateformat
<?php
$date = '01. 06. 2015';
$date = str_replace(' ', '', $date); // replace whitespaces
$mysqldate = date( 'Y-m-d H:i:s', strtotime($date));