JavaScript Tutorial/Date/getMinutes
Версия от 18:52, 25 мая 2010; (обсуждение)
Date().getMinutes()
The getMinutes() method returns the minutes portion of the Date object expressed as an integer from 0 to 59.
<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
<!--
dateVar = new Date();
alert(dateVar.getMinutes());
// -->
</script>
</head>
<body>
</body>
</html>
Display current time by using Date.getHours(), Date().getMinutes(), Date().getSeconds()
<html>
<head>
<title>Convert Time</title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
<!--
var current_date = new Date();
var hour_value = current_date.getHours();
var minute_value = current_date.getMinutes();
var second_value = current_date.getSeconds();
var AMorPM = "AM";
if (hour_value > 12)
{
hour_value -= 12;
AMorPM = "PM";
}
document.write("The current time is " + hour_value + ":" + minute_value +
":" + second_value + " " + AMorPM);
//-->
</script>
</body>
</html>