14,983
edits
(→now) |
|||
| Line 4: | Line 4: | ||
Convert '''time stamp''' <--> to the '''human readable time''' format | Convert '''time stamp''' <--> to the '''human readable time''' format | ||
=== now === | === now === | ||
the '''human readable''' time format ex: {{ | the '''human readable''' time format ex: {{Template:Today}} {{CURRENTTIME}}:06 | ||
* php: echo date("Y-m-d H:i:s", time() ); //Convert the time stamp of current time to the human readable time format. Ex: return '{{Template:Today}} | * php: echo date("Y-m-d H:i:s", time() ); //Convert the time stamp of current time to the human readable time format. Ex: return '{{Template:Today}} {{CURRENTTIME}}:06' | ||
* mysql: | * mysql: | ||
** {{kbd | key=<nowiki>SELECT NOW();</nowiki>}} Returns {{Template:Today}} | ** {{kbd | key=<nowiki>SELECT NOW();</nowiki>}} Returns {{Template:Today}} {{CURRENTTIME}}:06 which mapping to {{kbd | key=<nowiki>DATETIME</nowiki>}} type<ref>[http://dev.mysql.com/doc/refman/5.1/en/datetime.html MySQL :: MySQL 5.1 Reference Manual :: 11.3.1 The DATE, DATETIME, and TIMESTAMP Types]</ref> | ||
** {{kbd | key=<nowiki>SELECT NOW()+0;</nowiki>}} //2011-04-01 12:19:43 returns 20110401122023.000000 | ** {{kbd | key=<nowiki>SELECT NOW()+0;</nowiki>}} //2011-04-01 12:19:43 returns 20110401122023.000000 | ||
** {{kbd | key=<nowiki>SELECT CURRENT_TIMESTAMP;</nowiki>}} | ** {{kbd | key=<nowiki>SELECT CURRENT_TIMESTAMP;</nowiki>}} Returns {{Template:Today}} {{CURRENTTIME}}:06 {{exclaim}} [http://stackoverflow.com/questions/2934258/how-do-i-get-the-current-time-zone-of-mysql Current time zone of MySQL] is SYSTEM. | ||
* shell script in {{Linux}} or {{Mac}}: {{kbd | key=<nowiki>echo `date +\%Y-\%m-\%d\ %H:%M:%S` 2>&1</nowiki>}} Returns {{Template:Today}} {{CURRENTTIME}}:06 | |||
the current date | the current date | ||