zoukankan      html  css  js  c++  java
  • js Date 关于时间获取问题

    var date1 = new Date();
    
    var timeFormat = {
         'yyyy-mm-dd': date1 .toJSON().split('T')[0],  //"2017-01-06T06:01:23.271Z" => [ "2017-01-06", "05:40:29.068Z" ] => "2017-01-06"  
        'stamp': date1*1,
        'ch_date_time': date1.toLocaleFormat(),  //"2017年1月6日 14:04:12",
        'en_date‘:date1.toDateString(), //"Fri Jan 06 2017"
        'yyyy/m/d':date1.toLocaleDateString(), //"2017/1/6"
    ''toTimeString };

    let _r = [];
    $('#Conversion_getter+dl dt code').each(function(){
    _r.push($(this).text().replace('()','').split('.').pop());
    });
    let _d = new Date();
    _r.forEach((item, index)=>{
    let txt = 'error'
    try { txt = _d[item]()}
    catch(e) {}
    console.log(item, index,'=> ',txt)
    })




    toDateString 0 => Wed Jan 11 2017
    toISOString 1 => 2017-01-11T13:17:52.079Z
    toJSON 2 => 2017-01-11T13:17:52.079Z
    toGMTString 3 => Wed, 11 Jan 2017 13:17:52 GMT
    toLocaleDateString 4 => 2017/1/11
    toLocaleFormat 5 => error
    toLocaleString 6 => 2017/1/11 下午9:17:52
    toLocaleTimeString 7 => 下午9:17:52
    toSource 8 => error
    toString 9 => Wed Jan 11 2017 21:17:52 GMT+0800 (中国标准时间)
    toTimeString 10 => 21:17:52 GMT+0800 (中国标准时间)
    toUTCString 11 => Wed, 11 Jan 2017 13:17:52 GMT
    valueOf 12 => 1484140672079

    
    

    MDN: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Date

  • 相关阅读:
    函数练习之计算机
    函数练习小程序
    Java—Day5课堂练习
    mysql-用户权限管理
    liunx-tail 实时显示文件内容
    Linux-diff --比较两个文件并输出不同之处
    linux-查找某目录下包含关键字内容的文件
    mysql-允许远程连接
    mysql-基本操作
    liunx-指令
  • 原文地址:https://www.cnblogs.com/so-letitgo/p/6256126.html
Copyright © 2011-2022 走看看