CSharp examples for System:DateTime UTC
Converts an API datetime string to a UTC DateTime.
using System.Globalization; using System.Text; using System.Collections.Generic; using System;//from w ww.j a v a 2s . com public class Main{ /// <summary> /// Converts an API date/time string to a UTC DateTime. /// </summary> /// <param name="timeUTC"></param> /// <returns></returns> public static DateTime TimeStringToDateTime(this String timeUTC) { DateTime dt = DateTime.MinValue; // timeUTC = yyyy-MM-dd HH:mm:ss if (String.IsNullOrEmpty(timeUTC)) return dt; DateTime.TryParse(timeUTC, CultureConstants.DefaultCulture, DateTimeStyles.AdjustToUniversal, out dt); return dt; } }