Hallo,
How do I output the current Date and Time formatted how I want?
In VBA I'd use the Format$ function defined in the subject?
The code I have so far is:
(As you may be able to tell I'm a n00b with my roots in VBA - elementary my dear Watson)
The problem is, I want the month as 2 digits.
The help I have found gives information like:
But how do I include that in my $strDateTime code?
Gives an error:
Unexpected token '/"{02}' in expression or statement.
Any ideas?
- Frink
Is it just me, or is this getting worse...
How do I output the current Date and Time formatted how I want?
In VBA I'd use the Format$ function defined in the subject?
The code I have so far is:
Code:
$datDateTime=Get-Date
$strDateTime=""
$strDateTime=$strDateTime$datDateTime.Day
$strDateTime=$strDateTime"/"$datDateTime.Month
$strDateTime=$strDateTime"/"$datDateTime.Year
etc.
write-host "The current Date and Time is: "$strDateTime"."
The current Date and Time is: 12/2/2008.
The problem is, I want the month as 2 digits.
The help I have found gives information like:
Code:
"0:D2" -f $datDateTime.Month
Code:
$strDateTime=$strDateTime"/""0:D2" -f $datDateTime.Month
Unexpected token '/"{02}' in expression or statement.
Any ideas?
- Frink
Is it just me, or is this getting worse...