Convert To ISO Standard Date Time - CSharp System

CSharp examples for System:DateTime Convert

Description

Convert To ISO Standard Date Time

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from ww w.j  av a2s .co m*/

public class Main{
        public static DateTime? ConvertToISOStandardDateTime(this DateTime? obj, string value)
        {
            DateTime date = new DateTime();
            if (DateTime.TryParse(value, out date))
            {
                return date.ToUniversalTime();
            }
            return null;
        }
        public static DateTime ConvertToISOStandardDateTime(this DateTime obj, string value)
        {
            DateTime date = new DateTime();
            if (DateTime.TryParse(value, out date))
            {
                return date.ToUniversalTime();
            }
            return DateTime.MinValue;
        }
}

Related Tutorials