Show current time: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
Tags: Mobile edit Mobile web edit
 
(8 intermediate revisions 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 7: Line 7:


== Windows DOS ==
== Windows DOS ==
* {{kbd | key= date/t}} ({{Win}}) (parameter: /t will not ask you to change the current date)
Result of {{kbd | key= date/t}} ({{Win}}) (parameter: /t will not ask you to change the current date). By OS:
<pre>output:
 
OS in English: Thu 05/03/2012
* XP in English: {{kbd | key=Thu 05/03/2012}}
OS in Mandarin Chinese (XP): 2012/05/03 星期四
* XP in Mandarin: {{kbd | key=2012/05/03 星期四}}
OS in Mandarin Chinese (Windows 8, Windows Server 2008 R2): 2014/07/01 週二
* Windows 8, Windows Server 2008 R2 in Mandarin: {{kbd | key=2014/07/01 週二}}
OS in Mandarin Chinese (Windows 10): 週一 2019/12/02
* Windows Server 2019 Standard in Mandarin: {{kbd | key=週五 2024/03/01}}
</pre>
* Windows 10 in Mandarin: {{kbd | key=週一 2019/12/02}}
* {{kbd | key= <nowiki>prompt $d $t $_$P$G</nowiki>}} ({{Win}}<ref>[http://stackoverflow.com/questions/673523/how-to-measure-execution-time-of-command-in-windows-command-line batch file - How to measure execution time of command in windows command line? - Stack Overflow]</ref>)
 
<pre>output:
 
OS in Mandarin Chinese (Windows 10): 2017/02/03 週五 15:35:31.61
Result of {{kbd | key= <nowiki>prompt $d $t $_$P$G</nowiki>}} on {{Win}}<ref>[http://stackoverflow.com/questions/673523/how-to-measure-execution-time-of-command-in-windows-command-line batch file - How to measure execution time of command in windows command line? - Stack Overflow]</ref>). By OS:
 
* Windows 10 in Mandarin: {{kbd | key=2017/02/03 週五 15:35:31.61}}
* Windows Server 2019 Standard in Mandarin: {{kbd | key=週五 2024/03/01 16:43:30.32}}
 
Result of {{kbd | key= <nowiki>echo %DATE% %TIME%</nowiki>}} {{Win}}. By OS:
 
* Windows Server 2019 Standard in Mandarin: {{kbd | key=週五 2024/03/01 16:43:30.32}}
 
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%'
<pre>command:
php -r "echo date('Y-m-d);" > today.txt
SET /P TODAY =< today.txt
ECHO %TODAY%
</pre>
</pre>
output: `{{Template:Today}}`


== PHP & MySQL ==
== PHP & MySQL ==
[[PHP and MySQL syntax]]
[[PHP and MySQL syntax]]


* related pages: [[Time server]], [[PHP_and_MySQL_syntax#timestamp | timestamp in PHP and MySQL syntax]]


[[Category:Programming]] [[Category:Linux]] [[Category:Windows]]
[[PHP_and_MySQL_syntax#timestamp | timestamp in PHP and MySQL syntax]]
 
== Related pages ==
[[Time server]]
 
== References ==
<references />
 
[[Category:Programming]] [[Category:Linux]] [[Category:Windows]] [[Category:Time river]]

Latest revision as of 16:52, 1 March 2024

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 & macOS icon_os_mac.png ) example output: '2026-07-18 20:31: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]

Result of date/t (Win Os windows.png ) (parameter: /t will not ask you to change the current date). By OS:

  • XP in English: Thu 05/03/2012
  • XP in Mandarin: 2012/05/03 星期四
  • Windows 8, Windows Server 2008 R2 in Mandarin: 2014/07/01 週二
  • Windows Server 2019 Standard in Mandarin: 週五 2024/03/01
  • Windows 10 in Mandarin: 週一 2019/12/02


Result of prompt $d $t $_$P$G on Win Os windows.png [4]). By OS:

  • Windows 10 in Mandarin: 2017/02/03 週五 15:35:31.61
  • Windows Server 2019 Standard in Mandarin: 週五 2024/03/01 16:43:30.32

Result of echo %DATE% %TIME% Win Os windows.png . By OS:

  • Windows Server 2019 Standard in Mandarin: 週五 2024/03/01 16:43:30.32

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%'

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

output: `2026-07-18`

PHP & MySQL[edit]

PHP and MySQL syntax


timestamp in PHP and MySQL syntax

Related pages[edit]

Time server

References[edit]