js method to get the current system date and time

  • 2020-06-07 04:00:56
  • OfStack

This article illustrates how js gets the date and time of the current system. Share to everybody for everybody reference. Specific implementation methods are as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js Time to show </title>
var curr_time = new Date();
var strDate = curr_time.getYear()+" years ";
strDate += curr_time.getMonth()+1+" month ";
strDate += curr_time.getDate()+" day ";
strDate += curr_time.getHours()+":";
strDate += curr_time.getMinutes()+":";
strDate += curr_time.getSeconds();

var curr_time = new Date();
// Define the variable and assign it to the current year, followed by the Chinese character "year" 
var strDate = getYear()+1900+" years ";
// Take the current month. Notice that the months from 0 So let's start, so let's add 1 , followed by the Chinese character "month" logo 
strDate +=getMonth()+1+" month ";
strDate +=getDate()+" day "; // Take the current date, followed by the Chinese character "day" logo 
strDate +=getHours()+":"; // Take the current hour 
strDate +=getMinutes()+":"; // Take current minute 
strDate +=getSeconds(); // Take the current number of seconds 
alert(strDate); // Results output 

Hopefully, this article has been helpful in your javascript programming.

Related articles: