CSharp examples for System:DateTime Format
Format Time
using System.Threading.Tasks; using System.Text.RegularExpressions; using System.Text; using System.Linq; using System.Collections.Generic; using System;/*from w w w .j a v a 2s . c o m*/ public class Main{ public static String FormatTime(TimeSpan time) { string hourFormat = time.Hours.ToString(); if (time.Hours < 10) hourFormat = "0" + time.Hours.ToString(); string minuteFormat = time.Minutes.ToString(); if (time.Minutes < 10) minuteFormat = "0" + time.Minutes.ToString(); return hourFormat + ":" + minuteFormat; } }