15,075
edits
mNo edit summary |
No edit summary |
||
| (5 intermediate revisions by the same user not shown) | |||
| Line 88: | Line 88: | ||
= TEXT( (Unixtime / 86400) + 25569, "YYYY-mm-dd hh:mm:ss") | = TEXT( (Unixtime / 86400) + 25569, "YYYY-mm-dd hh:mm:ss") | ||
</pre> | </pre> | ||
=== MySQL way: convert to date from unix timestamp === | |||
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> | |||
SELECT FROM_UNIXTIME(IF(`timestamp_column` = 0, NULL, `timestamp_column`, "%Y-%m-%d %H:%i:%S") | |||
</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]] | ||