Mega Code Archive

 
Categories / C# / Date Time
 

Generate the timestamp of the provided DateTime

//----------------------------------------------------------------------- // <copyright file="Utilities.cs" company="Beemway"> //     Copyright (c) Beemway. All rights reserved. // </copyright> // <license> //     Microsoft Public License (Ms-PL http://opensource.org/licenses/ms-pl.html). //     Contributors may add their own copyright notice above. // </license> //----------------------------------------------------------------------- using System; using System.Globalization; using System.IO; using System.Linq; using System.Text; using System.Xml.Linq; using System.Xml.Serialization; namespace LinkedIn.Utility {   /// <summary>   /// A utilities class   /// </summary>   public static class Utilities   {     /// <summary>     /// Generate the timestamp of the provided <see cref="DateTime"/>.           /// </summary>     /// <param name="dateTime">The <see cref="DateTime"/> object.</param>     /// <returns>A timestamp.</returns>     public static string GenerateTimestamp(DateTime dateTime)     {       TimeSpan t = (dateTime - new DateTime(1970, 1, 1));       return ((long)t.TotalMilliseconds).ToString(CultureInfo.InvariantCulture);     }   } }