Advertisement
Guest User

Untitled

a guest
Aug 31st, 2015
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1.         // Generates a unix epoch timestamp
  2.         // They use DateTime of locale here (DateTime.Now)
  3.         public static String Timestamp(DateTime now)
  4.         {
  5.             DateTime e = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
  6.             TimeSpan t = now.Subtract(e);
  7.             // Decided to drop milliseconds
  8.             String timestr = ((int)(t.TotalSeconds)).ToString();
  9.             return timestr;
  10.         }
  11.  
  12.         // Generate a PerkTV formatted timestamp
  13.         // They use DateTime of locale here (DateTime.Now)
  14.         public static String TimeString()
  15.         {
  16.             DateTime localDate = DateTime.Now;
  17.             String timestamp_ = localDate.ToString("ddd, dd MMM yyyy HH:mm:ss K");
  18.             String t = timestamp_.Substring((timestamp_.Length - 1), 1);
  19.             if (t != "Z")
  20.             {
  21.                 t = timestamp_.Substring((timestamp_.Length - 2), 2);
  22.                 timestamp_ = timestamp_.Substring(0, (timestamp_.Length - 3)) + t;
  23.             }
  24.             timestamp_ = timestamp_.Replace(" ", "%20").Replace(":", "%3A").Replace(",", "%2C"); ;
  25.             return timestamp_;
  26.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement