To Unique String - CSharp System

CSharp examples for System:DateTime Format

Description

To Unique String

Demo Code

//      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;
        }
}

Related Tutorials