$myDate = date('m-d-Y 00:00:00', strtotime($myDate));
if($debugs)echo"<br>myDate is: $myDate in line: ".__line__."<br>";
$mysqlstart = date('Y-m-d 00:00:00', strtotime($myDate));
if($debugs)echo"<br>mysqlstart is: $mysqlstart in line: ".__line__."<br>";
From the code above, I would like to show $myDate to the audience while passing $mysqlstart into a query.
When I echo my query, the month is in the date spot and the date is in the month spot
so
instead of getting $mysqlstart as ‘2023-03-10’, I get an output of ‘2023-10-03’. Very odd.
I tried the above code expecting the date and month to switch for sql purposes but it exchanges the month and date in the incorrect pattern.
3
Answers
This is only a guess but is your pc in setup in English or United Kingdom or United States I think this is your problem good luck let me know if you get it fixed thanks Ian.
What’s the previous value of $myDate? In the first line of your code you are using it to pass its value to strtotime. Try something like this to get dates, obviously you can pass to mktime the date you want:
You can use the DateTime class to achive the result.
here a small example
The output of the script will be the following: