Conversion method:
var date = new Date (timestamp);
Get a Time object note: If the timestamp is Uinx, remember to multiply at 1000.
For example, PHP function time () to get the timestamp will be multiplied by 1000
//获取时间日期的方法date.getFullYear();//获取完整的年份(4位,1970)date.getMonth();//获取月份(0-11,0代表1月,用的时候记得加上1)date.getDate();//获取日(1-31)date.getTime();//获取时间(从1970.1.1开始的毫秒数)date.getHours();//获取小时数(0-23)date.getMinutes();//获取分钟数(0-59)date.getSeconds();//获取秒数(0-59)
Format method: Yyyy-mm-dd hh:mm:ss
//输出结果:2014-04-23 18:55:49
Convert date format to timestamp
Pass in a time format, if not passed is to get the current time, it is so simple.
There are three ways of getting
time1 = Date.gettime () time2 = date.valueof () Time3 = Date.parse (date)
Three types of acquisition the first, the second: it will be accurate to the millisecond third: only accurate to the second, milliseconds will be replaced by the number of
The result of the above code output
1398250549123
1398250549123
1398250549000
Note: Note: The time stamp obtained in addition to 1000 can get Unix timestamp, when the value of the PHP is used to get
Conversion between JS timestamp and date format