Hey, PowerShell Guy!, How do you know it's Morning or evening ?
I Paste the following into the Consolewindow :
switch (get-date -Format tt) {
'AM' {'It is morning time.'}
'PM' {'It is afternoon/evening time.'}
}
A variation on the Hey Scripting Guy article : How Can I Tell If a Time Occurred in the Morning or the Evening?
PS C:\scripts> switch (get-date -Format tt) {
>> 'AM' {'It is morning time.'}
>> 'PM' {'It is afternoon/evening time.'}
>> }
>>
It is morning time.
Oops it's morning time allready, time to go to bed ;-)
*Update*
No we are not text parsing ;-) as in the original article we can also provide a other time easy in any dateTime format and it still will work correctly :
PS C:\scripts> get-date -date 13:00 -Format tt
PM
PS C:\scripts> get-date -date 2007-12-14T01:27:17.5063395+01:00 -Format tt
AM
to get some more possible formats :
(get-date).GetDateTimeFormats()
enjoy,
Greetings /\/\o\/\/