zoukankan      html  css  js  c++  java
  • Powershell编程基础-002-日期及日期格式化

    在Powershell中,关于日期,时间计算与格式化,常用的如下:

    $today=Get-Date                                                                #今天的日期,格式:2020年8月27日 13:19:33


    echo $today.AddDays(1)                                                   #明天的日期:2020年8月28日 13:33:08
    echo $today.AddDays(-1)                                                  #昨天的日期:2020年8月26日 13:33:08
    echo $today.ToString('yyyy-MM-dd HH:mm:ss')               #格式化日期时间:2020-08-27 13:33:08

    综合使用(日期、时间综合计算):

    $today=Get-Date    
    echo $today.ToString('yyyy-MM-dd HH:mm:ss')                                                          #2020-08-27 13:50:05
    echo $today.AddDays(-1).AddHours(-2).AddMinutes(-3).AddSeconds(-4).ToString('yyyy-MM-dd HH:mm:ss')   #2020-08-26 11:47:01

    尊重别人的劳动成果 转载请务必注明出处:https://www.cnblogs.com/5201351/p/13570910.html

  • 相关阅读:
    c++ range库
    差分数组
    简单比较一下C++中的引用和指针
    数字图像处理中一张常用图片
    内存池与内存块
    SmartPtr
    Allocator
    Java学习第12天
    Java学习第11天
    Java学习第10天
  • 原文地址:https://www.cnblogs.com/5201351/p/13570910.html
Copyright © 2011-2022 走看看