Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Generates a unix epoch timestamp
- // They use DateTime of locale here (DateTime.Now)
- public static String Timestamp(DateTime now)
- {
- DateTime e = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
- TimeSpan t = now.Subtract(e);
- // Decided to drop milliseconds
- String timestr = ((int)(t.TotalSeconds)).ToString();
- return timestr;
- }
- // Generate a PerkTV formatted timestamp
- // They use DateTime of locale here (DateTime.Now)
- public static String TimeString()
- {
- DateTime localDate = DateTime.Now;
- String timestamp_ = localDate.ToString("ddd, dd MMM yyyy HH:mm:ss K");
- String t = timestamp_.Substring((timestamp_.Length - 1), 1);
- if (t != "Z")
- {
- t = timestamp_.Substring((timestamp_.Length - 2), 2);
- timestamp_ = timestamp_.Substring(0, (timestamp_.Length - 3)) + t;
- }
- timestamp_ = timestamp_.Replace(" ", "%20").Replace(":", "%3A").Replace(",", "%2C"); ;
- return timestamp_;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement