js 时间格式转毫秒数

var time= (new Date("2015/03/30 12:00:00")).getTime(); //得到毫秒数

//下面格式的时间需要转换:

var time = ‘2015-03-30 12:00:00‘;

time = time .replace(new RegExp("-","gm"),"/");

var times = (new Date(time )).getTime(); //得到毫秒数

//毫秒数转化为时间

var time = (new Date("2015/03/30 12:00:00")).getTime(); //得到毫秒数

var newTime = new Date(time ); //就得到普通的时间了

时间: 2024-08-29 19:08:54

js 时间格式转毫秒数的相关文章

将json格式日期(毫秒数)转成日常日期格式和日常格式时间对比

第一:是把生成的Json格式的时间转换,注意要看清楚时间的格式 function (cellval) { var date = new Date(parseInt(cellval.replace("/Date(", "").replace(")/", ""), 10)); var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1

js 时间格式转换

js时间格式转换 格式化时间转成时间戳 //格式化转时间戳(单位秒) function strtotime(strtime) { strtime = strtime.substring(0, 19); strtime = strtime.replace(/-/g, '/'); strtime = new Date(strtime).getTime() / 1000; return strtime; } 时间戳转格式化时间 //时间戳(单位秒)转格式化 function getMyDate(str

JS时间格式 GMT格式转换

JavaScript时间格式转换总结 1.当前系统区域设置格式(toLocaleDateString和toLocaleTimeString) 例子:(new Date()).toLocaleDateString() + " " + (new Date()).toLocaleTimeString()结果: 2008年1月29日 16:13:112.普通字符串(toDateString和toTimeString) 例子: (new Date()).toDateString() + &quo

java中从1970-1-1到当前时间之间的毫秒数转换为oracle date

java中System.currentTimeMillis()取到的是从1970-01-01 00:00:00.000到当前时间的毫秒数,一个long类型的值. 现在oracle数据库中某表中存取的是该值,需要将其转换为可读的date类型. current millis 中提供了TimeMillis的转换结果以及一些常用的转换方法. 但是其中关于pl/sql取得的数是精确到千毫秒,而不是精确到毫秒. 整理了一个包来进行currentTimeMillis到date的转换. 注意:System.cu

最简单的Js时间格式验证,含时分秒!

function isDatetime(date){   var regex=/^(?:19|20)[0-9][0-9]-(?:(?:0[1-9])|(?:1[0-2]))-(?:(?:[0-2][1-9])|(?:[1-3][0-1])) (?:(?:[0-2][0-3])|(?:[0-1][0-9])):[0-5][0-9]:[0-5][0-9]$/;   if(!regex.test(date)){    alert("格式不正确!请输入正确的时间格式,如:2010-07-07 09:12

java如何把时间格式转为毫秒

比如把String类型“201104141302” 转换成毫秒数?不胜感激! import java.text.ParseException;import java.text.SimpleDateFormat; public class Cat { public static void main(String[] args) throws ParseException { String str = "201104141302"; SimpleDateFormat sdf = new S

js 时间格式与时间戳的相互转换和计算几天后的日期是哪一天

//把日期转换成时间戳 function get_unix_time(time1){    var newstr = time1.replace(/-/g,'/');     var date =  new Date(newstr);     var time_str = date.getTime().toString();    return time_str.substr(0, 10);} 一.时间转换时间戳 function transdate(endTime){ var date=new

js时间格式转换

js调用的new Date()不是格式化的时间,例如 var date=new Date(); alert(date); 显示的结果:Wed Oct 14 22:28:32 UTC+0800 2015 今天这里分享一个js写的foramt()函数,希望能对大家有所帮助! function formate(datetime) { var year = datetime.getFullYear(); var month = datetime.getMonth() + 1; //js从0开始取 var

js时间格式转换的几种方法

公司项目需要获取时间并且转换格式,之前没有实现过但读过源码,新来的小哥给我讲了下细节.算是学到了..... 1 function getLocalTime(){ 2 var now=new Date(); 3 var year=now.getFullYear(); 4 var moth=now.getMonth()+1; 5 if(month<10){ 6 moth="0"+month; 7 } 8 var date=now.getDate(); 9 if(date<10)