0
I’m trying to convert a date that comes from a datapicker, the date comes in format dd/mm/yy
, but in order to work with it in mysql, I need it to be in the format yyyy-mm-dd
.
I’m using the following code:
$ini = $_POST['inicio'];
$newDateini = date( "Y-m-d", strtotime('$ini'));
$newDatefim = date("Y-m-d", strtotime($_POST['fim']));
PS: I could put the dateformat
as yy-mm-dd
in the datapicker, but this would make the date confusing for the user.
If I select today’s date, for example, and request a echo $ini
the result will be 28/05/2017
. But when I request a echo $newDateini
instead of returning the date in 2017-05-28
, returns to me as if the date is empty(1970-01-01
)
right... and what’s the problem?
– FReNeTiC
@Frenetic, I didn’t notice that I hadn’t asked the question halfway, sorry. I edited the question spelled out the problem
– Rick Parapinski
https://answall.com/a/21841/250 ;)
– Bruno Augusto