Sherzy
3/17/2016 - 4:49 PM

Format Dates for display

Format Dates for display

public string DateFormatted
{
    get
    {
        return String.Format( "{0:dddd, MMMM d, yyyy}", Date);
    }
}
public string TimeFormatted
{
    get
    {
        string daytime = "";
        if (StartTime != null)
        {
            daytime = String.Format( "{0:t}", StartTime);
            if (EndTime != null && EndTime > StartTime)
            {
                daytime += " - " + String .Format("{0:t}" , EndTime);
            }
        }
        return daytime;
    }
}
// for javascript
// In .NET application convert the DateTime object to a string like:
// 
// dtStr = dt.ToString("o"); // ISO 8601 standard date time format
// That way you won't have to worry about locale based differences 
// on date time strings and most languages should be able to handle 
// this format without a problem

public DateTime LastUpdateTime { get; set; }
public string LastUpdateTimeJS
{
    get
    {
        return LastUpdateTime.ToString("o"); 
    }
}