14,970
edits
No edit summary |
|||
| (4 intermediate revisions by the same user not shown) | |||
| Line 90: | Line 90: | ||
=== MySQL way: convert to date from unix timestamp === | === MySQL way: convert to date from unix timestamp === | ||
timezone: server timezone dependent {{exclaim}} | timezone: MySQL server timezone dependent {{exclaim}}<ref>[https://www.w3resource.com/mysql/date-and-time-functions/mysql-from_unixtime-function.php MySQL FROM_UNIXTIME() function]</ref> | ||
<pre> | <pre> | ||
SELECT FROM_UNIXTIME(IF(`timestamp_column` = 0, NULL, `timestamp_column`, "%Y-%m-%d % | SELECT FROM_UNIXTIME(IF(`timestamp_column` = 0, NULL, `timestamp_column`, "%Y-%m-%d %H:%i:%S") | ||
</pre> | </pre> | ||
=== MySQL way: convert to unix timestamp from date time === | |||
Using [https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_unix-timestamp UNIX_TIMESTAMP()] function | |||
timezone: MySQL server timezone dependent {{exclaim}} | |||
* {{kbd | key = SELECT UNIX_TIMESTAMP('2011-03-15 18:53:57');}} /* return timestamp: 1300186437 */ | |||
* {{kbd | key = SELECT UNIX_TIMESTAMP(STR_TO_DATE('2011-03-15 18:53:57', '%Y-%m-%d %H:%i:%S'));}} /* return timestamp: 1300186437 */ | |||
== References == | == References == | ||
<references /> | <references /> | ||
{{Template:Data factory flow}} | |||
[[Category:PHP]] [[Category:Programming]] | [[Category:PHP]] [[Category:Programming]] | ||