vb.netdatetimevcalendarvcal

Not getting correct time from UniversalDateTime


I send a vcal through mail in web application with convert datetime to universal datetime. If i run web application locally (local sevser in India) i get correct time in my vcal. But run appication live (server in US) then not get corret time with a difference of 1 and half hour.Please suggest me.

code :

Dim result As StringBuilder = New StringBuilder()
        result.AppendFormat("BEGIN:VCALENDAR{0}", System.Environment.NewLine)
        result.AppendFormat("BEGIN:VEVENT{0}", System.Environment.NewLine)
        result.AppendFormat("SUMMARY:{0}{1}", subject, System.Environment.NewLine)
        result.AppendFormat("LOCATION:{0}{1}", location, System.Environment.NewLine)
        result.AppendFormat("DTSTART:{0}{1}", startDate.ToUniversalTime().ToString("yyyyMMdd\THHmmss\Z"), System.Environment.NewLine)
        result.AppendFormat("DTEND:{0}{1}", endDate.ToUniversalTime().ToString("yyyyMMdd\THHmmss\Z"), System.Environment.NewLine)
        result.AppendFormat("DTSTAMP:{0}{1}", DateTime.Now.ToUniversalTime().ToString("yyyyMMdd\THHmmss\Z"), System.Environment.NewLine)
        result.AppendFormat("DESCRIPTION:{0}{1}", description, System.Environment.NewLine)
        result.AppendFormat("END:VEVENT{0}", System.Environment.NewLine)
        result.AppendFormat("END:VCALENDAR{0}", System.Environment.NewLine)
        Return result.ToString()

Solution

  • Since IST (India Standard Time) is at UTC+5:30 and the US time zones are at UTC-4 (Eastern) to UTC-7 (Pacific), you could appear to be one and a half hours off (actually, ten and a half hours off but ignoring am/pm) if the server is running in Central Daylight-Saving (CDT) time.

    I found vcalendar at www.vcalendar.org which swiftly redirects you. It appears to be a PHP application. And looking at the PHP manual, it appears that the H format is 24-hour time; but it requires a single H, not a double H. The PDF for the documentation at vcalendar.org is AWOL (404 - except it redirects you to a more useful page than simply 404, but it still isn't there!).

    Suggestion: establish which time zone your server is running in in the USA (there are 4 main time zones, and sundry auxilliary ones). Check whether the '1.5 hours = 10.5 hours modulo 12' hypothesis is plausible. And look hard at the date/time formats and the meaning of 'HH'.