时间戳转换日期

<script>
//第一种 格式为:2010/12/23 上午10:53
function getLocalTime(nS) {
return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/,‘ ‘);
}
alert(getLocalTime(1293072805));
//第二种 格式为:2010/12/23 上午10:53
function getLocalTime(nS) {
return new Date(parseInt(nS) * 1000).toLocaleString().substr(0,18)
}
alert(getLocalTime(1293072805));
//第三种 格式为:2010-10-20 10:00:00
function getLocalTime(nS) {
return new Date(parseInt(nS) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
}
alert(getLocalTime(1177824835));
</script>

时间: 2024-08-28 19:57:24

时间戳转换日期的相关文章

js时间戳转换日期格式和日期计算

一.时间戳转换日期 1 function formatDate(datetime) { 2 // 获取年月日时分秒值 slice(-2)过滤掉大于10日期前面的0 3 var year = datetime.getFullYear(), 4 month = ("0" + (datetime.getMonth() + 1)).slice(-2), 5 date = ("0" + datetime.getDate()).slice(-2), 6 hour = (&quo

时间戳转换日期格式 - Vue

日常开发中经常会遇到时间相关的问题,服务端返回的数据都是以时间戳的方式,那么需要将其处理转化为对应的时间格式,具体方式如下: 一.filters 中 formatDate 方法实现 <script> export default { name: "listItem", props:['datas'], data(){ return{ item:this.datas } }, methods:{ payClick(item){ this.$emit("payClic

Java 13位时间戳转换日期格式

1 import java.text.ParseException; 2 import java.text.SimpleDateFormat; 3 import java.util.Date; 4 5 public class DateUtil { 6 7 private static SimpleDateFormat sf = null; 8 9 /** 10 * 获取系统时间 11 */ 12 public static String getCurrentDate() { 13 Date d

时间戳转换日期格式

[原创出品§转载请注明出处] 出处:http://www.cnblogs.com/libra13179/p/5796082.html 文件下载地址:http://files.cnblogs.com/files/libra13179/sw_wall_clock.zip /** *@brief: monthLength *@details: Get month length. *@param[in] uint8_t lpyr 1 for leap year, 0 if not. *@param[in

JS /jquery 时间戳与日期转换

(function($) { $.extend({ myTime: { /** * 当前时间戳 * @return <int> unix时间戳(秒) */ CurTime: function(){ return Date.parse(new Date())/1000; }, /** * 日期 转换为 Unix时间戳 * @param <string> 2014-01-01 20:20:20 日期格式 * @return <int> unix时间戳(秒) */ DateT

jquery 时间戳与日期转换

(function($) { $.extend({ myTime: { /** * 当前时间戳 * @return <int> unix时间戳(秒) */ CurTime: function(){ return Date.parse(new Date())/1000; }, /** * 日期 转换为 Unix时间戳 * @param <string> 2014-01-01 20:20:20 日期格式 * @return <int> unix时间戳(秒) */ DateT

java 日期转时间戳,时间戳转为日期

package date; import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.Date; public class test { public static void main(String[] args) { Date d = new Date(); String beginDate = "1435845268096"; SimpleDateFormat sdf = n

jquery 时间戳和日期时间转化

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 (function($) {     $.extend({         myTime: {             /**              * 当前时间戳          

PHP时间戳和日期相互转换

在php中我们要把时间戳转换日期可以直接使用date函数来实现,如果要把日期转换成时间戳可以使用strtotime()函数实现,下面我来给大家举例说明. 1.php中时间转换函数 strtotime (date()) date("Y-m-d H:i",$unixtime) 2.php中获得今天零点的时间戳 要获得零点的unix时间戳,可以使用 $todaytime=strtotime(“today”), 然后再使用 date("Y-m-d H:i",$todayti