xxxxxxxxxx
// Get current time
const currentDate = new Date();
// Format the time to 24-hour format
const currentHours = ('0' + currentDate.getHours()).slice(-2); // Add leading zero if necessary
const currentMinutes = ('0' + currentDate.getMinutes()).slice(-2);
// Construct the time string
const currentTime = `${currentHours}:${currentMinutes}`;
// Display the current time
console.log(currentTime);
xxxxxxxxxx
DateTime now = DateTime.Now;
string time24 = now.ToString("HH:mm:ss");
Console.WriteLine(time24);
xxxxxxxxxx
var date = new Date();
console.log(date.toLocaleString('en-GB'));
xxxxxxxxxx
var time = new Date();
console.log(time.getMinutes());
console.log(time.getHours());
xxxxxxxxxx
var options = { hour12: false };
console.log(date.toLocaleString('en-US', options));