Export (0) Print
Expand All
Expand Minimize

Converting VBScript's Hour Function


Windows PowerShell


Definition: Returns a whole number between 0 and 23, inclusive, representing the hour of the day.

Hour

Not that days, months, and years aren't important, mind you, but sometimes all you really need to know is the hour. To return an integer value indicating the hour (based on a 24-hour clock) just use the Get-Date Cmdlet and take a peek at the value of the Hour property:



$a = (get-date).hour

When you run this command at 4:00 PM and then echo back the value of $a you should get the following:



16


Return to the VBScript to Windows PowerShell home page

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft