Urgent!! Greenwich Mean Time? 
Author Message
 Urgent!! Greenwich Mean Time?

Hi,

I am creating an Outlook 2000 forms based application using VBScript that
will be used by a few teams in US as well as London.  The teams want all
times to be displayed as GMT.  Is there a function in VBScript that converts
any date into GMT (like toUTCString and toLocaleString methods in JScript)?
How do you suggest I go about it?  Thanks for any help...



Sat, 10 May 2003 03:00:00 GMT  
 Urgent!! Greenwich Mean Time?
Grrrr. No, there isn't, and I had hoped the function would show up in recent
editions of the vbscript engine. Has anyone else worked a similar issue and
come up with a decent workaround other than some gymnastics to use
JavaScript for the GMT?


Quote:
> Hi,

> I am creating an Outlook 2000 forms based application using VBScript that
> will be used by a few teams in US as well as London.  The teams want all
> times to be displayed as GMT.  Is there a function in VBScript that
converts
> any date into GMT (like toUTCString and toLocaleString methods in
JScript)?
> How do you suggest I go about it?  Thanks for any help...



Sat, 10 May 2003 03:00:00 GMT  
 Urgent!! Greenwich Mean Time?
This was just a personal exercise I did about a year ago.  It works fine but you may want to clean
up the variable names ;-)...

msgbox FormatUTC(now)

function FormatUTC(ByVal vDate)
  '================================================
  'Converts input date/time to Universal Time
  'Coordinate (UTC) in the same format as JScript's
  'Date().toUTCString() method.
  '
  ' dayabbreviation, dd monthname yy hh:mm:ss UTC
  '
  'Example: Fri, 2 Jul 1999 18:17:50 UTC
  '
  '================================================
  if isdate(vdate) then
    vdate = cdate(vdate)
  else
    err.raise &h7001,"FormatUTC","Argument is not a valid date"
  end if

  set shell = createobject("wscript.shell")

  'ActiveTimeBias is the number of minutes that UTC
  'is offset from local time.  It is added to local
  'date/time to get UTC equivalent.
  '
  strValueName = _
    "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\"_
  & "TimeZoneInformation\ActiveTimeBias"
  tmpTimeOffset = shell.regread(strValueName)

  'ActiveTimeBias can be REG_BINARY or REG_DWORD
  'depending on the OS version...
  '
  if IsArray(tmpTimeOffset) then
    'it's REG_BINARY w/ 2 bytes significant
    lngTimeOffset = tmpTimeOffset(0) + (tmpTimeOffset(1)*(2^8))
  else
    'it's REG_DWORD
    lngTimeOffset = tmpTimeOffset
  end if
  dt = DateAdd("n", lngTimeOffset, vDate)

  'Extract the "fields" of the date/time and
  'reformat into UTC standard format.
  '
  dayabbr = weekdayname(weekday(dt),True) 'abbreviated

  'JScript doesn't include leading 0 on day,
  'so we don't either.
  '
  dd = datepart("d",dt)
  monnm = monthname(month(dt),true)
  yyyy = year(dt)

  hh = right("00" & hour(dt),2)
  mn = right("00" & minute(dt),2)
  ss = right("00" & second(dt),2)

  FormatUTC = _
      dayabbr & ", " _
    & dd & " " & monnm & " " & yyyy & " " _
    & hh & ":" & mn & ":" & ss _
    & " UTC"

end function

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup...
--

Quote:

> Hi,

> I am creating an Outlook 2000 forms based application using VBScript that
> will be used by a few teams in US as well as London.  The teams want all
> times to be displayed as GMT.  Is there a function in VBScript that converts
> any date into GMT (like toUTCString and toLocaleString methods in JScript)?
> How do you suggest I go about it?  Thanks for any help...



Sat, 10 May 2003 03:00:00 GMT  
 Urgent!! Greenwich Mean Time?
Thanks for the code snippet -- perhaps this should be a separate questions,
but if you want to stab at it here...

In general, given an ASP delivery environment -- i.e., the end product of my
development efforts will be viewed by users through a browser -- what kinds
of functionality should I tend to look FIRST to the wscript.shell object to
provide? So far, my short list includes reading the server registry for
values of import, but I'm guessing there might be others...

Regards,

Bret Hern


Quote:
> This was just a personal exercise I did about a year ago.  It works fine

but you may want to clean
Quote:
> up the variable names ;-)...

> msgbox FormatUTC(now)

> function FormatUTC(ByVal vDate)
>   '================================================
>   'Converts input date/time to Universal Time
>   'Coordinate (UTC) in the same format as JScript's
>   'Date().toUTCString() method.
>   '
>   ' dayabbreviation, dd monthname yy hh:mm:ss UTC
>   '
>   'Example: Fri, 2 Jul 1999 18:17:50 UTC
>   '
>   '================================================
>   if isdate(vdate) then
>     vdate = cdate(vdate)
>   else
>     err.raise &h7001,"FormatUTC","Argument is not a valid date"
>   end if

>   set shell = createobject("wscript.shell")

>   'ActiveTimeBias is the number of minutes that UTC
>   'is offset from local time.  It is added to local
>   'date/time to get UTC equivalent.
>   '
>   strValueName = _
>     "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\"_
>   & "TimeZoneInformation\ActiveTimeBias"
>   tmpTimeOffset = shell.regread(strValueName)

>   'ActiveTimeBias can be REG_BINARY or REG_DWORD
>   'depending on the OS version...
>   '
>   if IsArray(tmpTimeOffset) then
>     'it's REG_BINARY w/ 2 bytes significant
>     lngTimeOffset = tmpTimeOffset(0) + (tmpTimeOffset(1)*(2^8))
>   else
>     'it's REG_DWORD
>     lngTimeOffset = tmpTimeOffset
>   end if
>   dt = DateAdd("n", lngTimeOffset, vDate)

>   'Extract the "fields" of the date/time and
>   'reformat into UTC standard format.
>   '
>   dayabbr = weekdayname(weekday(dt),True) 'abbreviated

>   'JScript doesn't include leading 0 on day,
>   'so we don't either.
>   '
>   dd = datepart("d",dt)
>   monnm = monthname(month(dt),true)
>   yyyy = year(dt)

>   hh = right("00" & hour(dt),2)
>   mn = right("00" & minute(dt),2)
>   ss = right("00" & second(dt),2)

>   FormatUTC = _
>       dayabbr & ", " _
>     & dd & " " & monnm & " " & yyyy & " " _
>     & hh & ":" & mn & ":" & ss _
>     & " UTC"

> end function

> --
> Michael Harris
> Microsoft.MVP.Scripting
> --

> Please do not email questions - post them to the newsgroup...
> --




- Show quoted text -

Quote:
> > Hi,

> > I am creating an Outlook 2000 forms based application using VBScript
that
> > will be used by a few teams in US as well as London.  The teams want all
> > times to be displayed as GMT.  Is there a function in VBScript that
converts
> > any date into GMT (like toUTCString and toLocaleString methods in
JScript)?
> > How do you suggest I go about it?  Thanks for any help...



Sun, 11 May 2003 15:02:50 GMT  
 Urgent!! Greenwich Mean Time?

Quote:

> Thanks for the code snippet -- perhaps this should be a separate questions,
> but if you want to stab at it here...

> In general, given an ASP delivery environment -- i.e., the end product of my
> development efforts will be viewed by users through a browser -- what kinds
> of functionality should I tend to look FIRST to the wscript.shell object to
> provide? So far, my short list includes reading the server registry for
> values of import, but I'm guessing there might be others...

On the server side you can use any COM objects that are available on the server (given the
constraints of the IUSR_machinename account unless you use authentication).

On the client, there are not that many "safe for scripting" ActiveX (COM) objects that you can
assume are installed on the client.  Of the things that come with a WSH install, only the Dictionary
object is safe.  Everything else gives script access to client side machine resources which
*doesn't* fit in the browser based security model.  Besides, it limits you to IE only since Netscape
doesn't support ActiveX.

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup...
--



Sun, 11 May 2003 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. how to calculate the GMT (greenwich mean time)

2. Greenwich Mean Time

3. HELP: getting Greenwich Mean Time

4. Converting Greenwich Mean Time

5. Greenwich Mean Time

6. Converting Greenwich Mean Time

7. Convert Greenwich Mean Time to EST

8. How to Convert GMT(Greenwich) Time to short date and time and vice versa

9. How Can I Obtain Greenwich Mean Time in VB?

10. URGENT: Report works the first time, but not the second time

11. Please, someone, help me (2nd time) it's urgent

12. Career Opertunity: Computer Consultant, Greenwich, London

 

 
Powered by phpBB® Forum Software