CSharp examples for System:DateTime Format
To Unique String
// Copyright (c) 2014-2015 OSharp. All rights reserved. using System.Linq; using System;//from w ww .j a va2s. c om public class Main{ public static string ToUniqueString(this DateTime dateTime, bool milsec = false) { int sedonds = dateTime.Hour * 3600 + dateTime.Minute * 60 + dateTime.Second; string value = string.Format("{0}{1}{2}", dateTime.ToString("yy"), dateTime.DayOfYear, sedonds); return milsec ? value + dateTime.ToString("fff") : value; } }