Results 1 to 2 of 2

Thread: UTC Date trouble

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780

    UTC Date trouble

    I need to have a vbscript run every hour. This script need to dynamically get the previous UTC hour.
    Example If it runs at 9 AM Est I need it to return: 8amUTC and 9am UTC.

    I can create the timestamps well enough but when I try to use them I don't think that the system is looking at them as valid date formats. If I hardcode the values into the script it will work. So I must be creating these incorrectly. Does anyone have a better solution than how I am doing this?

    Code:
    od = now() 
    set oShell = CreateObject("WScript.Shell") 
    atb = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias" 
    offsetMin = oShell.RegRead(atb) 
    nd = dateadd("n", offsetMin, od)
    
    StartTime = Year(Date)&"-" & Month(Date)&"-"&Day(Date)&"T"&(Hour(nd)-1)&":00:00Z"
    EndTime = Year(Date)&"-" & Month(Date)&"-"&Day(Date)&"T"&Hour(nd)&":00:00Z"
    
    'StartTime ="2010-11-01T19:00:00.00Z"
    'EndTime="2010-11-01T20:00:00.00Z"
    
    wscript.echo StartDate
    wscript.echo EndDate
    "...Men will still say THIS was our finest hour"
    If a tree falls in the woods and no one is there to see it, do all the other trees make fun of it?

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: UTC Date trouble

    Maybe using DateSerial function or CDate function to convert the dates, will help

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width