September 2009
M T W T F S S
« Aug   Oct »
 123456
78910111213
14151617181920
21222324252627
282930  

ThaiBuddhistCalendar and DateTime Convertion

//date time utc
        DateTime _utc = DateTime.UtcNow;

        // utc --> thai
        ThaiBuddhistCalendar tbc = new ThaiBuddhistCalendar();

        int thaiDay = tbc.GetDayOfMonth(_utc);
        int thaiMonth = tbc.GetMonth(_utc);
        int thaiYearr = tbc.GetYear(_utc);

        string thaiDaate = thaiDay.ToString("00") + "/" + thaiMonth.ToString("00") + "/" + thaiYearr.ToString("0000");

        // thai --> utc
        DateTime _do, _UtcTime;
        DateTime.TryParseExact(thaiDaate, "dd/MM/yyyy", new CultureInfo("th-TH"), DateTimeStyles.None, out _do);
        _UtcTime = _do.ToUniversalTime();
ref: http://msdn.microsoft.com/en-us/library/system.globalization.thaibuddhistcalendar.getera.aspx

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>