How to calculate the StartTime / UntilTime parameter using Get-Printer in Powershell?
Solution 1
I believe both values are calculated in minutes since 12:00 AM GMT. That would put you in GMT+2. Does that work out properly?
Solution 2
Just to clarify on this - there are multiple tricks on this question:
1) Johnathan is right - it is a trick question. The trick, though, comes from the fact that a user can submit a job at ANY time to the printer, regardless of the availability of the printer. The job will just hold in queue until StartTime is reached - at which time, it will print.
2) As mentioned before, the printer is paused. Nothing prints, although users can send jobs at any time.
3) StartTime and UntilTime are computed using UTC, regardless of the time zone and they are in minutes. So, if you set your StartTime to 0100 UTC, it will show as "60". This trick uses "1000" to fool you into thinking it is "10 o'clock". It is actually 4:40pm UTC. "60" is going to be 1:00am UTC. "600" is going to be 10:00am UTC.
4) Since the question does not indicate the Time Zone, the times aren't going to matter, because the clock times given in the question aren't going to be the same, say, for me in UTC-7, for someone in UTC+2. So...ANOTHER trick.
But, deciphering the tricks teaches us a lot.
At least Microsoft isn't using epoch time for this.
-Tzo
Solution 3
The Starttime and Untiltime values are in minutes. The maximum value is 1440 (minutes) that equals to 24 hours.
The trick is to know what is the actual time zone set, to be able to identify which time the value represents. For example:
In UTC Coordinated Universal Time, 0 = 12:00am (that is easy to calculate since each value correspond to a minute, 60 = 01:00am, 120 = 02:00am, etc.)
In UTC+01:00, 0 = 01:00am (just add 1 hour from midnight to know where is the value 0. then 60 will be 02:00am, 120 = 03:00am, etc.)
In UTC-03:00, 0 = 09:00pm (subtract 3 hours from midnight you get 0, then 60 will be 10:00pm and so on)
For questions related to a get-printer result, check the status of the printer too, if it's paused, the printer wont print, even if it is during the available time. If the question does not say anything about the time zone your in, I guess it is not possible to know which time the value represents.
Related videos on Youtube
Ivan Viktorovic
Updated on September 18, 2022Comments
-
Ivan Viktorovic over 1 year
I have an printer setup using the GUI and set the printer availabilty from 18:40 until 3:00 As well i got the PS command "Get-Printer Printer1 | format-list"
The result of the command puts out:
StartTime 1000 UntilTime 60
Now im kinda depressed i cant figure out how the hell 18:40 is represented as the value 1000 and 3:00 as the value 60.
I tried to find the answer via google but the technical references are only giving me information like
-StartTime UInt32 -- Specifies the starting time of printer availability.
So my question is how do i calculate the value represented by the parameter StartTime and UntilTime? If needed i can add more values. Just cant figure it out.
-
Ivan Viktorovic almost 10 yearsSo UntilTime 120 should be 4:00. It seems to be right. Thanks.
-
Ivan Viktorovic about 9 yearsGermany is GMT/UTC + 1h during Standard Time Germany is GMT/UTC + 2h during Daylight Saving Time