Home > Web Front-end > JS Tutorial > js time formatting

js time formatting

大家讲道理
Release: 2016-11-10 13:34:44
Original
1119 people have browsed it

To convert a string into time, I found that the js time format has the following types

new Date("month dd,yyyy hh:mm:ss"); 
new Date("month dd,yyyy"); 
new Date(yyyy,mth,dd,hh,mm,ss); 
new Date(yyyy,mth,dd); 
new Date(ms);
Copy after login

Instructions:

month: Use English to represent the name of the month, from January to December
mth: Use an integer to represent the month, from 0 (January ) to 11 (December)

Content


dd: indicates the day of the month, from 1 to 31
yyyy: four-digit year
hh: hour, from 0 (midnight) to 23 (11 p.m.)
mm: Minutes, an integer from 0 to 59
ss: Seconds, an integer from 0 to 59
ms: Milliseconds, an integer greater than or equal to 0, indicating the time and sum that need to be created The number of milliseconds difference between GMT time on January 1, 1970.

//字符串转时间 格式 2012-08-12 23:13:15  
function mypaseDate(str){  
    str = str.replace(/-/g,"/");  
    var date = new Date(str);  
}
Copy after login
rrree


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