troubleshooting Question

modify function to get 24-hour clock

Avatar of sirbounty
sirbountyFlag for United States of America asked on
VB Script
4 Comments1 Solution706 ViewsLast Modified:
I have this function to schedule a job on servers all over the world approximately 3 hours from 'now'.
Usage for the function:
      arrStart=Split(TimeToRun(objItem.CurrentTimeZone)," ")
      StartDate=arrStart(0)
      StartTime=arrStart(1)

Problem is, due to the 24-hour clock used within schtasks, it's not hitting it correctly in some instances (2am instead of 2pm/1400).
Anyone willing to feed this thing some brain-power?
Function TimeToRun(tz)
    Const OffSet=180
    Set colItems = objWMI.ExecQuery("Select * From Win32_LocalTime")
    For Each objItem in colItems
      With objItem
        LocalDateString=.Month & "/" & .Day & "/" & .Year & " " & .Hour & ":" & .Minute & ":" & .Second
      End With
    Next
 
    GMT=DateAdd("n",-(tz),LocalDateString)
    NewGMTtime=DateAdd("n",OffSet,GMT)
    TimeToRun=DateAdd("n",tz,newGMTTime)
  End Function
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros