![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Hi Friends,
My mail goal is to get the UTC time for local zone. I am facing problems in handling internation time zones in VBScript for Item.Start and Item.End. Could any one tell me in brief/code to handle different international time zones. I thought of the below solution: 1. Get the UTC time 2. Get the time difference with local zone 3. Add it to UTC. Is there any ways to do this in VBScript? Thanks in Advance, Megha |
Ads |
#2
|
|||
|
|||
![]()
You'd need to use WSH (Windows Scripting) to read the registry to get those
settings. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "masani paresh" wrote in message ... Hi Friends, My mail goal is to get the UTC time for local zone. I am facing problems in handling internation time zones in VBScript for Item.Start and Item.End. Could any one tell me in brief/code to handle different international time zones. I thought of the below solution: 1. Get the UTC time 2. Get the time difference with local zone 3. Add it to UTC. Is there any ways to do this in VBScript? Thanks in Advance, Megha |
#3
|
|||
|
|||
![]()
We can do it in VB like below:
Dim testTime As DateTime = DateTime.Now Debug.WriteLine(testTime.ToString) Debug.WriteLine(testTime.ToUniversalTime.ToString) Is there any function in VBScript that can convert local time to UTC? Thanks, Paresh "Ken Slovak - [MVP - Outlook]" wrote: You'd need to use WSH (Windows Scripting) to read the registry to get those settings. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "masani paresh" wrote in message ... Hi Friends, My mail goal is to get the UTC time for local zone. I am facing problems in handling internation time zones in VBScript for Item.Start and Item.End. Could any one tell me in brief/code to handle different international time zones. I thought of the below solution: 1. Get the UTC time 2. Get the time difference with local zone 3. Add it to UTC. Is there any ways to do this in VBScript? Thanks in Advance, Megha |
#4
|
|||
|
|||
![]()
That's using VB.NET.
There are no equivalents in VBScript or Windows scripting for ToUniveralTime(). You'd have to write your own function for that. Or you could search on the Web to see if anything like that has been done using VBScript or possibly VBA or VB6. If you found code in VB6 or VBA you'd need to translate it into VBScript code. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "masani paresh" wrote in message ... We can do it in VB like below: Dim testTime As DateTime = DateTime.Now Debug.WriteLine(testTime.ToString) Debug.WriteLine(testTime.ToUniversalTime.ToString) Is there any function in VBScript that can convert local time to UTC? Thanks, Paresh |
#5
|
|||
|
|||
![]()
Thanks Ken, I have done it in following way.
sTime = Format(Item.Start,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "+" & timeOffset) eTime = Format(Item.End,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "+" & timeOffset) I have hard coded time offsets for different time zone that is required. I am getting local site and corresponding time zone offset and adding it to current time to get the UTC. Could you see any improvement that i can make here. Thanks, Paresh "Ken Slovak - [MVP - Outlook]" wrote: That's using VB.NET. There are no equivalents in VBScript or Windows scripting for ToUniveralTime(). You'd have to write your own function for that. Or you could search on the Web to see if anything like that has been done using VBScript or possibly VBA or VB6. If you found code in VB6 or VBA you'd need to translate it into VBScript code. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "masani paresh" wrote in message ... We can do it in VB like below: Dim testTime As DateTime = DateTime.Now Debug.WriteLine(testTime.ToString) Debug.WriteLine(testTime.ToUniversalTime.ToString) Is there any function in VBScript that can convert local time to UTC? Thanks, Paresh |
#6
|
|||
|
|||
![]()
Keep in mind that the offsets will be different depending on whether
Daylight Savings Time (DST) is observed and whether the given date falls with the DST. Keep in mind that on the MAPI level, these propertiss are already stored in UTC, so you can simply access teh raw MAPI properties using Extended MAPI, CDO 1.21, or Redemption. plug Redemption (url below) exposes time zones through the RDOSession.Timeszones collection - http://www.dimastr.com/redemption/rdo/rdotimezones.htm /plug -- Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool - "masani paresh" wrote in message ... Thanks Ken, I have done it in following way. sTime = Format(Item.Start,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "+" & timeOffset) eTime = Format(Item.End,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "+" & timeOffset) I have hard coded time offsets for different time zone that is required. I am getting local site and corresponding time zone offset and adding it to current time to get the UTC. Could you see any improvement that i can make here. Thanks, Paresh "Ken Slovak - [MVP - Outlook]" wrote: That's using VB.NET. There are no equivalents in VBScript or Windows scripting for ToUniveralTime(). You'd have to write your own function for that. Or you could search on the Web to see if anything like that has been done using VBScript or possibly VBA or VB6. If you found code in VB6 or VBA you'd need to translate it into VBScript code. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "masani paresh" wrote in message ... We can do it in VB like below: Dim testTime As DateTime = DateTime.Now Debug.WriteLine(testTime.ToString) Debug.WriteLine(testTime.ToUniversalTime.ToString) Is there any function in VBScript that can convert local time to UTC? Thanks, Paresh |
#7
|
|||
|
|||
![]()
I'd agree with Dmitry that you aren't handling DST dates and hard coding
offsets is not a good way to go. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "masani paresh" wrote in message ... Thanks Ken, I have done it in following way. sTime = Format(Item.Start,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "+" & timeOffset) eTime = Format(Item.End,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "+" & timeOffset) I have hard coded time offsets for different time zone that is required. I am getting local site and corresponding time zone offset and adding it to current time to get the UTC. Could you see any improvement that i can make here. Thanks, Paresh |
#8
|
|||
|
|||
![]()
Dmitry, You are right. I used following code to get the time zone but it says
"ActiveX component cannot create object: Redeption.RDOSession" Could you help me. set Session = CreateObject("Redemption.RDOSession") set Timezones = Session.Timezones for each TZ in Timezones MsgBox TZ.Name next Thanks, Paresh "Dmitry Streblechenko" wrote: Keep in mind that the offsets will be different depending on whether Daylight Savings Time (DST) is observed and whether the given date falls with the DST. Keep in mind that on the MAPI level, these propertiss are already stored in UTC, so you can simply access teh raw MAPI properties using Extended MAPI, CDO 1.21, or Redemption. plug Redemption (url below) exposes time zones through the RDOSession.Timeszones collection - http://www.dimastr.com/redemption/rdo/rdotimezones.htm /plug -- Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool - "masani paresh" wrote in message ... Thanks Ken, I have done it in following way. sTime = Format(Item.Start,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "+" & timeOffset) eTime = Format(Item.End,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "+" & timeOffset) I have hard coded time offsets for different time zone that is required. I am getting local site and corresponding time zone offset and adding it to current time to get the UTC. Could you see any improvement that i can make here. Thanks, Paresh "Ken Slovak - [MVP - Outlook]" wrote: That's using VB.NET. There are no equivalents in VBScript or Windows scripting for ToUniveralTime(). You'd have to write your own function for that. Or you could search on the Web to see if anything like that has been done using VBScript or possibly VBA or VB6. If you found code in VB6 or VBA you'd need to translate it into VBScript code. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "masani paresh" wrote in message ... We can do it in VB like below: Dim testTime As DateTime = DateTime.Now Debug.WriteLine(testTime.ToString) Debug.WriteLine(testTime.ToUniversalTime.ToString) Is there any function in VBScript that can convert local time to UTC? Thanks, Paresh |
#9
|
|||
|
|||
![]()
Hi Ken,
I have written following steps to get the UTC value of current time by reading reg keys. But when it executes the set oShell = CreateObject("WScript.Shell") statement, it show the dialog box for confirming some installation. I have to click yes then it will proceed and works fine. Could you tell me how to make this statement to work silently. startTime = Item.Start endTime = Item.End set oShell = CreateObject("WScript.Shell") atb = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\" &_ "Control\TimeZoneInformation\ActiveTimeBias" offsetMin = oShell.RegRead(atb) startTime = dateadd("n", offsetMin, startTime) endTime = dateadd("n", offsetMin, endTime) startTime = Format(startTime,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "Z") endTime = Format(endTime,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "Z") MsgBox startTime & vbcrlf & endTime Thanks, Paresh "Ken Slovak - [MVP - Outlook]" wrote: You'd need to use WSH (Windows Scripting) to read the registry to get those settings. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "masani paresh" wrote in message ... Hi Friends, My mail goal is to get the UTC time for local zone. I am facing problems in handling internation time zones in VBScript for Item.Start and Item.End. Could any one tell me in brief/code to handle different international time zones. I thought of the below solution: 1. Get the UTC time 2. Get the time difference with local zone 3. Add it to UTC. Is there any ways to do this in VBScript? Thanks in Advance, Megha |
#10
|
|||
|
|||
![]()
It shouldn't if WSH is installed already. I never get that prompt when
instantiating a WSH object. What happens if you try that line from a simple VBS file you can create using Notepad? Do you always get the same prompt: Set oShell = CreateObject("WScript.Shell") -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "masani paresh" wrote in message ... Hi Ken, I have written following steps to get the UTC value of current time by reading reg keys. But when it executes the set oShell = CreateObject("WScript.Shell") statement, it show the dialog box for confirming some installation. I have to click yes then it will proceed and works fine. Could you tell me how to make this statement to work silently. startTime = Item.Start endTime = Item.End set oShell = CreateObject("WScript.Shell") atb = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\" &_ "Control\TimeZoneInformation\ActiveTimeBias" offsetMin = oShell.RegRead(atb) startTime = dateadd("n", offsetMin, startTime) endTime = dateadd("n", offsetMin, endTime) startTime = Format(startTime,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "Z") endTime = Format(endTime,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "Z") MsgBox startTime & vbcrlf & endTime Thanks, Paresh |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
how do I automatically display start time in calendar item | Ed B. | Outlook - Calandaring | 0 | March 28th 08 12:40 PM |
Item.Save and Item.Close Script causes Outlook 2007 to Crash | Rayyan | Outlook - Using Forms | 6 | November 25th 06 03:14 AM |
Saving exception item in recurring appointment item fails | Dikbill | Outlook and VBA | 2 | July 11th 06 03:59 PM |
How do I display item start times? | JessChamp | Outlook - Calandaring | 0 | May 2nd 06 11:16 PM |
How can I set a calender appointment start and end time zones | teebaldwin | Outlook - Calandaring | 3 | March 30th 06 05:28 PM |