Home > Article > Web Front-end > js time formatting
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);
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); }rrree