15,079
edits
m (→Debug) |
|||
| (3 intermediate revisions by the same user not shown) | |||
| Line 158: | Line 158: | ||
// output: 2021-03-29 | // output: 2021-03-29 | ||
$date = DateTime::createFromFormat('M d D Y | $date = DateTime::createFromFormat('M d D Y H:i', "Jun 04 Sun 2023 08:25"); | ||
echo $date->format('Y-m-d H:i:s'); | echo $date->format('Y-m-d H:i:s'); | ||
// output: 2023-06-04 08:25:00 | // output: 2023-06-04 08:25:00 | ||
</pre> | </pre> | ||
==== Convert date time from | The following instruction written by ChatGPT | ||
[[Convert date time from | <pre> | ||
// The input datetime string | |||
$input = "Jun 04 Sun 2023 08:25"; | |||
// Specify the input format | |||
$inputFormat = "M d D Y H:i"; | |||
// Create a DateTime object from the input string | |||
$dateTime = DateTime::createFromFormat($inputFormat, $input); | |||
// Check if the DateTime object was created successfully | |||
if ($dateTime === false) { | |||
echo "Failed to parse the input datetime string."; | |||
} else { | |||
// Format the DateTime object into the desired ISO format | |||
$isoFormat = "Y-m-d H:i:s"; | |||
$output = $dateTime->format($isoFormat); | |||
// Print the output | |||
echo $output; // "2023-06-04 08:25:00" | |||
} | |||
</pre> | |||
==== Convert date time from Zulu format ==== | |||
[[Convert date time from zulu format]] e.g. {{Template:Today}}T10:59:39.000Z | |||
==== Previous month based on current month ==== | ==== Previous month based on current month ==== | ||
| Line 407: | Line 431: | ||
# (optional) Adjust the text size to 10 | # (optional) Adjust the text size to 10 | ||
== | == Debug == | ||
[[SQL syntax debug]] | PHP | ||
* [https://www.php.net/manual/en/function.debug-backtrace.php PHP: debug_backtrace - Manual] | |||
MySQL | |||
* [[SQL syntax debug]] | |||
== References == | == References == | ||