1、toLocaleDateString (根据本地时间把Date 对象的日期部分转换为字符串):

  1. var time = new Date();
  2. var formatTime = time.toLocaleDateString();
  3.  
  4. //print
  5. 2017/4/18

2、将时间指定为 年-月-日 格式,例:2017-1-1

  1. var date = new Date('Thu May 12 2016 08:00:00 GMT+0800 (中国标准时间)');
  2.  
  3. formatTime=date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
  4.  
  5. //print formatTime
  6. 2016-9-20

这里要注意月份的获取,表示月份的参数介于 0 到 11 之间,所以如果想获得当前真实月份,还需 +1。

中国标准时间改为formatTime格式的更多相关文章

  1. js中国标准时间转换成datetime格式

    var format = function (time, format) { var t = new Date(time); var tf = function (i) { return (i < ...

  2. 中国标准时间、‘yyyy-MM-dd’格式时间转为时间戳

    中国标准时间转为时间戳 let _time="Tue Mar 20 2018 00:00:00 GMT+0800 (中国标准时间)"; console.log(Date.parse ...

  3. 【JavaScript】标准日期、中国标准时间、时间戳、毫秒数互转

    转载自:https://blog.csdn.net/IT429/article/details/78341847 看到的一篇比较有用的前端js时间转换方法,留个备份 首先要明确这三种格式是什么样子的: ...

  4. 【转】JS中,中国标准时间转化为yyyy-MM-dd

    'Thu May 12 2016 08:00:00 GMT+0800 (中国标准时间)'--此格式日期无法传到java后台,须格式化,方法如下 var d = new Date('Thu May 12 ...

  5. js 时间戳 中国标准时间 年月日 日期之间的转换

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  6. 批量将某一目录下的.py文件改为.txt格式文件

    #!/usr/env/python#-*- coding:utf-8 -*-#批量将某一目录下的.py文件改为.txt格式文件import os,os.pathfile_list = os.listd ...

  7. xss 防止攻击,恶意用户将输入的信息当成html或js代码执行,办法是将用户输入的信息改为text格式,或特殊符号转义

    xss 防止攻击,恶意用户将输入的信息当成html或js代码执行,办法是将用户输入的信息改为text格式,或特殊符号转义 XSS攻击的防范 XSS攻击造成的危害之所以会发生,是因为用户的输入变成了可执 ...

  8. 将中国标准时间转成yyyy-MM-dd

    public static void main(String[] args) throws ParseException { String s = "Tue Jul 12 00:00:00 ...

  9. 用pandas库修改excel文件里的内容,并把excel文件格式存为csv格式,再将csv格式改为html格式

    假设有Excel文件data.xlsx,其中内容为: ID  age  height     sex  weight张三   1   39     181  female      85李四   2  ...

随机推荐

  1. 微信小程序 按钮点击跳转页面

    wx.navigateTo({ url: '/pages/index/talkPage', })跳转到talkPage界面.   首先: html界面要在app.json里面注册:   不注册的话会报 ...

  2. 如何释放vector变量

    std::vector<cv::Point> probp; std::vector<int> plabel; plabel.clear(); std::vector<in ...

  3. HihoCoder - 1781: Another Bubble Sort (冒泡排序&逆序对)

    Sample Input 3 9 8 7 5 1 9 2 6 4 3 1 2 3 4 5 6 7 8 9 9 8 7 5 1 9 2 6 4 3 1 2 5 4 3 6 7 8 9 9 8 7 5 1 ...

  4. CodeForces - 1073E :Segment Sum (数位DP)

    You are given two integers l l and r r (l≤r l≤r ). Your task is to calculate the sum of numbers from ...

  5. 20155316 2016-2017-2 《Java程序设计》第5周学习总结

    教材学习内容总结 这周总结 try catch语法 异常继承结构 throw finally AutoCloseable接口 Collection Map Lambda表达式 上周总结 三个关键 类与 ...

  6. LG2024 [NOI2001]食物链

    拆点法 用并查集维护每种动物的同类.天敌.食物群 #include<cstdio> int fa[300005]; int n,k,ans; inline int read() { int ...

  7. java类库 java API jar包 C语言函数库

    翁凯说:java的强大是因为类库的强大 C/C++强大是因为函数库 在程序中用到系统提供的标准函数库中的输入输出函数时 应在程序的开头写上一行:#include"stdio.h"或 ...

  8. git代码回退

    情况1.还没有push可能 git add ,commit以后发现代码有点问题,想取消提交,用: reset git reset [--soft | --mixed | --hard] eg:  gi ...

  9. hive 数据导出三种方式

    今天我们再谈谈Hive中的三种不同的数据导出方式.根据导出的地方不一样,将这些方式分为三种:(1).导出到本地文件系统:(2).导出到HDFS中:(3).导出到Hive的另一个表中.为了避免单纯的文字 ...

  10. ballerina 学习二十六 项目docker 部署&& 运行(二)

    ballerina 从发布,到现在官方文档的更新也是很给力的,同时也有好多改进,越来越好用了 可以参考官方文档 https://ballerina.io/learn/by-guide/restful- ...