Get ISO Standard Date Time - CSharp System

CSharp examples for System:DateTime Format

Description

Get ISO Standard Date Time

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//w  ww .j ava2s  . co m

public class Main{
        public static string GetISOStandardDateTime(this DateTime value)
        {
            return value.ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
        }
        public static string GetISOStandardDateTime(this DateTime? value)
        {
            if (value.HasValue)
            {
                return value.Value.ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
            }
            else
            {
                return string.Empty;
            }
        }
}

Related Tutorials