Page 1 of 1

Hour and Minutes togheter in Javascript

Posted: 21 Jan 2022, 17:53
by JanMolendijk
Dear Coursesweb I can not find out how to add the hours + minutes togheter.

Code: Select all

<SCRIPT LANGUAGE="JavaScript"> 
day = new Date() 
hr = day.getHours() 
mn = day.getMinutes() 
se = day.getSeconds() 


</SCRIPT> 

 
I would like to have both in one ???? hr + mn ????

Code: Select all


hr = day.getHours() 
mn = day.getMinutes() 

miho = hr,mn ?????????????????????

This is the exmple what is working seperated

Code: Select all

if (hr == 1) document.write("Het is na enen. nog niet naar bed?") 

if (se == 1) document.write("<br>1  Wat gaat er gebeuren ?") 
if (mn == 52) document.write("Na22222zessen. De afwas al gedaan?") 


Hour and Minutes togheter in Javascript

Posted: 22 Jan 2022, 05:36
by MarPlo
See and use the following example:

Code: Select all

<script>
var day = new Date();
let hr = day.getHours();
let mn = day.getMinutes();
let se = day.getSeconds();

let st_hm ='Hour: '+hr+', minutes: '+mn;
document.write(st_hm);
</script>