DateTime To Local String - CSharp System

CSharp examples for System:DateTime Format

Description

DateTime To Local String

Demo Code


using System;/*w w  w.  java2  s  .com*/

public class Main{
        public static string ToLocalString(this DateTime? value, string format = null)
        {
            if (value == null) return "";
            var date = value.Value.ToLocalTime();
            if (format != null)
            {
                return date.ToString(format);
            }
            return date.ToString();
        }
}

Related Tutorials