Home > Web Front-end > JS Tutorial > body text

A small example of zero padding in js date and time_javascript skills

WBOY
Release: 2016-05-16 17:40:55
Original
1251 people have browsed it

Copy code The code is as follows:

function getNowFormatDate()
                                                  day = new Date();
var Year = 0;
var Month = 0;
var Day = 0;
var CurrentDate = "";
var CurrentDate = "";
var Month = 0; 🎜> //Year = day.getYear();//There is a bug that displays 108 in 2008 under Firefox
Year = day.getFullYear();//It can be used under Firefox
Month = day.getMonth() 1 ;
Day = day.getDate();
CurrentDate = Year "-";
if (Month >= 10 )
Current Date = Month "-";
}
else
{
CurrentDate = "0" Month "-";
}
if (Day >= 10 )
{
CurrentDate = Day ;
                                                                                                                                                                                                                                                                                        >         }

 
//obtained The time will be filled with zeros
var nowdate = getNowFormatDate();



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template