[英]powershell : how to format get-date to string and remove 0's?
I'm attempting to eliminate leading any leading zeroes in my date when I run the get-date cmdlet by trying: 我尝试通过运行get-date cmdlet来消除日期中的前导零。
$filedate = get-date -uformat "%m-%d-%Y"
$filedate = $filedate.ToString().Replace("0", "")
this returns "01-04-2008" 这将返回“ 01-04-2008”
I want to the output to be "1-4-2008" 我希望输出为“ 1-4-2008”
any ideas on another way of doing this? 有其他想法可以做到这一点吗?
thanks in advance 提前致谢
$filedate = get-date -format "M-d-yyyy"
$ fileDate = $ fileDate.ToString(“ Md-yyyy”)
use format string like : 使用格式字符串,例如:
get-date -format yyyy/M/d
or 要么
get-date.tostring(yyyy/M/d) get-date.tostring(yyyy / M / d)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.