var str = '2008-10-09 21:35:28';//PHP中对应的UNIX时间戳为1223559328
var new_str = str.replace(/:/g,'-');
new_str = new_str.replace(/ /g,'-');
var arr = new_str.split("-");
document.write("<b>原始日期</b>: "+str);
var datum = new Date(Date.UTC(arr[0],arr[1]-1,arr[2],arr[3]-8,arr[4],arr[5]));
document.write("<br><b>转换后的UNIX时间戳为</b>: "+(datum.getTime()/1000));
var datum = new Date(datum.getTime());
document.write("<br><b>还原到原始日期为</b>: "+datum.toLocaleString());

JS将日期转化为unix时间戳的更多相关文章

  1. delphi java 日期 转换 获取Unix时间戳

    获取Unix时间戳 http://www.cnblogs.com/findumars/p/4716753.html 最简单准确一句话 Result:=IntToStr(  DateTimeToUnix ...

  2. Linux命令date日期时间和Unix时间戳互转

    A.将日期转换为Unix时间戳将当前时间以Unix时间戳表示: date +%s 输出如下: 1361542433 转换指定日期为Unix时间戳: date -d '2013-2-22 22:14' ...

  3. Java 日期时间与unix时间戳之间转换

    日期时间  <-->  时间戳 java.time 包提供的新的日期和时间API LocalDateTime: 本地日期时间类 ZoneId: 时区类 ZonedDateTime: 带时区 ...

  4. js 中日期2013-08-30或2019-08-24 12:30:00 转换成时间戳,和2019-08-29T02:15:08.000+0000转化为2019-08-29T02:15:08

    js 中日期2019-08-24 或2019-08-24 12:30:00 转换成时间戳 首先将它转成date日期类型,然后获取毫秒形式时间戳 let date=new Date("2019 ...

  5. JS中Unix时间戳转换日期格式

    <!doctype html> <html> <head> <title>Unix时间戳转换成日期格式</title> <script ...

  6. js 取得 Unix时间戳(Unix timestamp)

    js 取得 Unix时间戳 Unix时间戳(Unix timestamp),或称Unix时间(Unix time).POSIX时间(POSIX time),是一种时间表示方式,定义为从格林威治时间19 ...

  7. 获取当前的时间,转化为char[]格式unix时间戳

    /* 在这个程序当中实现获取当前的unix时间戳 转化为char[] */ #include<stdio.h> #include<stdlib.h> #include<t ...

  8. js unix时间戳转换

    一.unix时间戳转普通时间: var unixtime=1358932051; var unixTimestamp = new Date(unixtime* 1000); commonTime = ...

  9. mysql UNIX时间戳与日期的相互转换 查询表信息

    UNIX时间戳转换为日期用函数FROM_UNIXTIME() select FROM_UNIXTIME(1156219870); 日期转换为UNIX时间戳用函数UNIX_TIMESTAMP() Sel ...

随机推荐

  1. linux下连接无线网出现nl80211: Could not configure driver mode nl80211: deinit ifname=wlan1 disabled_11b_rates=0 wlan1: Failed to initialize driver interface

    一.背景1.1 jello@jello:~$ lsb_release -aNo LSB modules are available.Distributor ID:    UbuntuDescripti ...

  2. 委托的begininvoke

    http://blog.csdn.net/cml2030/article/details/2172854 http://blog.163.com/weizhiyong_111/blog/static/ ...

  3. 【附7】turbine

    一.作用 聚集同一个微服务的相同的commandKey.Threadpool.commandGroupKey数据进行聚合 二.配置 1.集群(cluster)(turbine聚集数据的粒度) turb ...

  4. Facebook广告API系列 3 Ads Management

    Facebook广告API系列 3 Facebook marketing API有三大组成部分: Audience Management Ads Management Ads Insights 本篇介 ...

  5. Ubuntu 14.04 vi 退格键不能删除字符

    执行命令 sudo apt-get install vim

  6. python 元组元素反转

    #create a tuple x = ("w3resource") # Reversed the tuple y = reversed(x) print(tuple(y)) #c ...

  7. windows cmd 命令和 linux 命令

    windows cmd 命令和 linux 命令 常用的内部命令有md.cd.rd.dir.path.copy.type.edit.ren.del.cls.ver.date.time.prompt.常 ...

  8. SQLServer中获取所有数据库名、所有表名、所有字段名的SQL语句

    ----1. 获取所有的数据库名----- SELECT NAME FROM MASTER.DBO.SYSDATABASES ORDER BY NAME -----2. 获取所有的表名------ S ...

  9. selenium-webdriver 简单教程

    ruby环境下selenium/webdriver可以通过selenium-webdriver.gem包进行安装 gem install selenium-webdriver   支持语言及版本有ru ...

  10. 从celery rabbitmq with docker-compose 引出对容器、依赖注入、TDD的感悟

    用docker配置项目管理系统taiga的时候,不是我一个人遇到这个问题.https://github.com/douglasmiranda/docker-taiga/issues/5 问题描述: 用 ...