Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

powershell : how to format get-date to string and remove 0's?

Tags:

powershell

I'm attempting to eliminate leading any leading zeroes in my date when I run the get-date cmdlet by trying:

$filedate = get-date -uformat "%m-%d-%Y" 
$filedate = $filedate.ToString().Replace("0", "")

this returns "01-04-2008"

I want to the output to be "1-4-2008"

any ideas on another way of doing this?

thanks in advance

like image 324
phill Avatar asked Dec 04 '08 17:12

phill


1 Answers

$fileDate = $fileDate.ToString("M-d-yyyy")

like image 156
EBGreen Avatar answered Oct 05 '22 17:10

EBGreen