zoukankan      html  css  js  c++  java
  • angular4中日期格式的用法

    dateTime: Date;
    
    this.dataTime = new Date(); //  获取当前日期
    // Wed Apr 18 2018 10:54:47 GMT+0800 (中国标准时间)

    欢迎加入前端交流群交流知识&&获取视频资料:749539640

    所有date中所有的tostring的方法.

    console.log('orderdate:', this.OrderDate);
            console.log('toISOString:', this.OrderDate.toISOString());
            console.log('toDateString:', this.OrderDate.toDateString());
            console.log('toUTCString:', this.OrderDate.toUTCString());
            console.log('toJSON:', this.OrderDate.toJSON());
            console.log('toLocaleDateString:', this.OrderDate.toLocaleDateString());
            console.log('toLocaleString:', this.OrderDate.toLocaleString());
            console.log('toLocaleTimeString:', this.OrderDate.toLocaleTimeString());
            console.log('toString:', this.OrderDate.toString());
            console.log('toTimeString:', this.OrderDate.toTimeString());
    
            //  输出结果:
            //  toISOString: 2017-12-07T16:33:01.843Z
            //  toDateString: Fri Dec 08 2017
            //  toUTCString: Thu, 07 Dec 2017 16:33:01 GMT
            //  toJSON: 2017-12-07T16:33:01.843Z
            //  toLocaleDateString: 2017/12/8
            //  toLocaleString: 2017/12/8 上午12:33:01
            //  toLocaleTimeString: 上午12:33:01
            //  toString: Fri Dec 08 2017 00:33:01 GMT+0800 (中国标准时间)
            //  toTimeString: 00:33:01 GMT+0800 (中国标准时间)

    日期前台展现的用法:

    前台html页面日期格式化: 
    
    {{ dateTime | date:'yyyy-MM-dd HH:mm:ss'}}
    
    {{ dateTime | date:'medium' }}
    
    {{ dateTime | date:'short' }}
    
    {{ dateTime | date:'fullDate' }}
    
    {{ dateTime | date:'longDate' }}
    
    {{ dateTime | date:'mediumDate' }}
    
    {{ dateTime | date:'shortDate' }}
    
    {{ dateTime | date:'mediumTime' }}
    
    {{ dateTime | date:'shortTime' }}
  • 相关阅读:
    贝叶斯定理
    用matplotlib统计数据并画图
    词云图
    一行python代码能写出啥?
    用python生成二维码
    18个python的高效编程技巧
    django简介
    vue点击变色
    selenium破解人人登陆验证码
    selenium请求豆瓣网
  • 原文地址:https://www.cnblogs.com/wangzhichao/p/8872775.html
Copyright © 2011-2022 走看看