将yyyy-MM-dd hh:mm:ss转换为时间戳

时间:2020-11-03 19:09:28   收藏:0   阅读:382
			// 转为时间戳//2014-07-10 10:21:12的时间戳为:1404958872 
			zhuanhuan(stringTime){
				// var stringTime = "2014-07-10 10:21:12";
				var timestamp2 = stringTime.replace(/-/g, ‘/‘)   //为了兼容IOS,需先将字符串转换为‘2018/9/11 9:11:23‘
				timestamp2 = Date.parse(timestamp2)    //返回‘2018-9-12 9:11:23‘的时间戳
				console.log(stringTime + "的时间戳为:" + timestamp2);
				return timestamp2;
			},

  

原文:https://www.cnblogs.com/fdxjava/p/13921414.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!