常用日期格式

1.    (get-date -Format 'R') -replace '(?i)[a-z]{3},\s([0-9]{2})\s([a-z]{3})\s([0-9]{4})\s.*', '$2-$1-$3'
May-19-2014
 
2.    (get-date -Format 'R').substring(5,11) -replace '\s', '-'
19-May-2014
 
3.    (get-date -Format 'R').split(' ')[1,2,3] -join '-'
19-May-2014
 
4.    (get-date).Tostring("dd-MMM-yyyy")
19-5月-2014
 
$date= Get-Date
foreach ($format in "d","D","f","F","g","G","m","r","s","t","T","u","U","y","dddd, MMMM dd yyyy","M/yy","dd-MM-yy") { 
"DATE with $format:{0}" -f $date.ToString($format)
}
 
DATE with d : 2015/5/6
DATE with D : 2015年5月6日
DATE with f : 2015年5月6日 16:42
DATE with F : 2015年5月6日 16:42:06
DATE with g : 2015/5/6 16:42
DATE with G : 2015/5/6 16:42:06
DATE with m : 5月6日
DATE with r : Wed, 06 May 2015 16:42:06 GMT
DATE with s : 2015-05-06T16:42:06
DATE with t : 16:42
DATE with T : 16:42:06
DATE with u : 2015-05-06 16:42:06Z
DATE with U : 2015年5月6日 8:42:06
DATE with y : 2015年5月
DATE with dddd, MMMM dd yyyy : 星期三, 五月 06 2015
DATE with M/yy : 5/15
DATE with dd-MM-yy : 06-05-15

转载于:https://www.cnblogs.com/IvanChen/p/4492369.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值