System time: Difference between revisions

Add Ecstasy example
(→‎{{header|Vlang}}: Rename "Vlang" in "V (Vlang)")
(Add Ecstasy example)
(6 intermediate revisions by 5 users not shown)
Line 956:
 
<syntaxhighlight lang="text">print timestr systime</syntaxhighlight>
 
=={{header|Ecstasy}}==
<syntaxhighlight lang="ecstasy">
module WhatTimeIsIt {
@Inject Clock clock;
@Inject Console console;
 
void run() {
console.print($"current time: {clock.now}");
}
}
</syntaxhighlight>
 
{{out}}
<pre>
current time: 2024-04-30 19:40:57.124
</pre>
 
=={{header|Elena}}==
Line 1,287 ⟶ 1,304:
}</syntaxhighlight>{{out}}
Mon Jun 21 13:02:19 BST 2010
 
Or using a <code>DateZonedDateTime</code> object:<syntaxhighlight lang="java">import java.utiltime.DateZonedDateTime;
 
public class SystemTime{
public static void main(String[] args){
Datevar now = new DateZonedDateTime.now();
System.out.println(now); // string representation
 
System.out.println(now.getTime()); // Unix time (# of milliseconds since Jan 1 1970)
//System.currentTimeMillis() returns the same value
}
}</syntaxhighlight>
 
Alternately, you can use a <tt>Calendar</tt> object, which allows you to retrieve specific fields of the date.
 
=={{header|JavaScript}}==
 
<syntaxhighlight lang="javascript">console.log(new Date()) // => Sat, 28 May 2011 08:22:53 GMT
console.log(Date.now()) // => 1306571005417 // Unix epoch</syntaxhighlight>
 
=={{header|Joy}}==
<syntaxhighlight lang="joy">time localtime "%T\n" strftime putchars.</syntaxhighlight>
 
=={{header|jq}}==
Line 1,470 ⟶ 1,485:
elapsed_real_time();
elapsed_run_time();</syntaxhighlight>
 
=={{header|Microsoft Small Basic}}==
Date and time follows the user's locale.
<syntaxhighlight lang="smallbasic">TextWindow.WriteLine(Clock.Date + " " + Clock.Time)</syntaxhighlight>
{{out}}
<pre>02/12/2022 8:27:15 PM
Press any key to continue...</pre>
 
=={{header|min}}==
Line 1,983 ⟶ 2,005:
See TimeList()
</syntaxhighlight>
 
=={{header|RPL}}==
Since 1990, there is a command named <code>TICKS</code> which returns the system time in 1/8192ths of a second, using a 64-bit unsigned integer:
{{out}}
<pre>
1: #1DBC0D1698BE0h
</pre>
There is also a <code>TIME</code> command, returning the system time in a hh.mmss format:
 
'''Output:'''
1: 20.4526471679 <span style="color:grey">@ 8:45:26 PM</span>
 
=={{header|Ruby}}==
Line 2,198 ⟶ 2,231:
{{libheader|Wren-date}}
Although Wren CLI can tell how much time has elapsed since the script started, it currently has no way of knowing what the time was then or what the time is now (in the current locale) unless the user passes the former as a command line argument.
<syntaxhighlight lang="ecmascriptwren">import "os" for Process
import "./date" for Date
 
var args = Process.arguments
Line 2,247 ⟶ 2,280:
 
{{omit from|Axe}}
{{omit from|bc}}
{{omit from|dc}}
162

edits