Convert To Display Date Time - CSharp System

CSharp examples for System:DateTime

Description

Convert To Display Date Time

Demo Code


using Microsoft.AspNet.Membership.OpenAuth;
using System.Linq;
using System.Collections.Generic;
using System;/* ww  w .  ja  v a 2  s  . c  om*/

public class Main{
        protected static string ConvertToDisplayDateTime(DateTime? utcDateTime)
        {
            // You can change this method to convert the UTC date time into the desired display
            // offset and format. Here we're converting it to the server timezone and formatting
            // as a short date and a long time string, using the current thread culture.
            return utcDateTime.HasValue ? utcDateTime.Value.ToLocalTime().ToString("G") : "[never]";
        }
}

Related Tutorials