Difference between revisions of "Show current time"

From LemonWiki共筆
Jump to navigation Jump to search
(One intermediate revision by the same user not shown)
Line 1: Line 1:
Multiple approached to show current time
How to show current time
== Linux BASH ==
== Linux BASH ==
Line 40: Line 40:
<references />
<references />
[[Category:Programming]] [[Category:Linux]] [[Category:Windows]]
[[Category:Programming]] [[Category:Linux]] [[Category:Windows]] [[Category:Time river]]

Latest revision as of 18:48, 4 December 2019

How to show current time

Linux BASH[edit]

  • date (Linux Os linux.png ) output the system date: 'Thu Oct 25 15:05:10 CST 2012' [1][2]
    • echo $(date '+%Y-%m-%d %H:%M:%S') (Linux Os linux.png & Mac Os mac.png ) example output: '2020-07-16 03:50:06' Icon exclaim.gif server timezone dependent
  • TZ=Asia/Taipei date (Linux Os linux.png ) output the time from the Taipei/CST timezone [3]

Windows DOS[edit]

  • date/t (Win Os windows.png ) (parameter: /t will not ask you to change the current date)
OS in English: Thu 05/03/2012
OS in Mandarin Chinese (XP): 2012/05/03 星期四
OS in Mandarin Chinese (Windows 8, Windows Server 2008 R2): 2014/07/01 週二
OS in Mandarin Chinese (Windows 10): 週一 2019/12/02
  • prompt $d $t $_$P$G (Win Os windows.png [4])
OS in Mandarin Chinese (Windows 10): 2017/02/03 週五 15:35:31.61

If PHP was installed. (1) Saved the PHP execution result to the file `today.txt` (2) Read the file content and save to the variable '%TODAY%'

php -r "echo date('Y-m-d);" > today.txt
SET /P TODAY =< today.txt

output: `2020-07-16`

PHP & MySQL[edit]

PHP and MySQL syntax

timestamp in PHP and MySQL syntax

Related pages[edit]

Time server