This language bar is your friend. Select your favorite languages!
Select your favorite languages :
- Or search :
X : constant String :=
Ada.Calendar.Formatting.Image (D) (12 .. 19);
Image returns date as well therefore the slice
let f = new Intl.DateTimeFormat(undefined, {
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hourCycle: 'h24'
}), x = f.format(d)
const d = new Date();
let hr = d.getHours();
let min = d.getMinutes();
let sec = d.getSeconds();
if ( hr.toString().length === 1 ) {
hr = '0' + hr;
}
if ( min.toString().length === 1 ) {
min = '0' + min;
}
if ( sec.toString().length === 1 ) {
sec = '0' + sec;
}
const x = '' + hr + ':' + min + ':' + sec;
Call `.toString().length` to check if zero padding needed.
Date d = getInstance().getTime();
String x = "%tT".formatted(d);
long d = currentTimeMillis();
String x = "%tH:%<tM:%<tS".formatted(d);
$d = DateTime->now;
$x = $d->hms;
The DateTime module provides easy access to the time of a datetime object as a HH:MM:SS string by invoking the method hms().
let format = format_description!("[hour]:[minute]:[second]");
let x = d.format(&format).expect("Failed to format the time");
(define d (current-date))
(define x (substring (date-and-time d) 11 19))
Chez Scheme; `date-and-time` always returns string with the same format and same length
programming-idioms.org