3 people like it.

Timestamp with timezone (YYYYMMDDhhmmssffff+zzzz)

Timestamp: Time format in ISO 8601 with timezone. YYYYMMDDhhmmssffff+zzzz For example 2011-05-17 19:01:10.000 -0200 would be: 20110517190110000-0200

1: 
2: 
3: 
4: 
let myTimeStamp = 
    let zone = System.TimeZone.CurrentTimeZone.GetUtcOffset System.DateTime.Now
    let prefix = match (zone<System.TimeSpan.Zero) with | true -> "-" | _ -> "+"
    System.DateTime.UtcNow.ToString("yyyyMMddHHmmssffff") + prefix + zone.ToString("hhss");     
val myTimeStamp : string

Full name: Script.myTimeStamp
val zone : System.TimeSpan
namespace System
type TimeZone =
  member DaylightName : string
  member GetDaylightChanges : year:int -> DaylightTime
  member GetUtcOffset : time:DateTime -> TimeSpan
  member IsDaylightSavingTime : time:DateTime -> bool
  member StandardName : string
  member ToLocalTime : time:DateTime -> DateTime
  member ToUniversalTime : time:DateTime -> DateTime
  static member CurrentTimeZone : TimeZone
  static member IsDaylightSavingTime : time:DateTime * daylightTimes:DaylightTime -> bool

Full name: System.TimeZone
property System.TimeZone.CurrentTimeZone: System.TimeZone
System.TimeZone.GetUtcOffset(time: System.DateTime) : System.TimeSpan
Multiple items
type DateTime =
  struct
    new : ticks:int64 -> DateTime + 10 overloads
    member Add : value:TimeSpan -> DateTime
    member AddDays : value:float -> DateTime
    member AddHours : value:float -> DateTime
    member AddMilliseconds : value:float -> DateTime
    member AddMinutes : value:float -> DateTime
    member AddMonths : months:int -> DateTime
    member AddSeconds : value:float -> DateTime
    member AddTicks : value:int64 -> DateTime
    member AddYears : value:int -> DateTime
    ...
  end

Full name: System.DateTime

--------------------
System.DateTime()
   (+0 other overloads)
System.DateTime(ticks: int64) : unit
   (+0 other overloads)
System.DateTime(ticks: int64, kind: System.DateTimeKind) : unit
   (+0 other overloads)
System.DateTime(year: int, month: int, day: int) : unit
   (+0 other overloads)
System.DateTime(year: int, month: int, day: int, calendar: System.Globalization.Calendar) : unit
   (+0 other overloads)
System.DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int) : unit
   (+0 other overloads)
System.DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, kind: System.DateTimeKind) : unit
   (+0 other overloads)
System.DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, calendar: System.Globalization.Calendar) : unit
   (+0 other overloads)
System.DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, millisecond: int) : unit
   (+0 other overloads)
System.DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, millisecond: int, kind: System.DateTimeKind) : unit
   (+0 other overloads)
property System.DateTime.Now: System.DateTime
val prefix : string
Multiple items
type TimeSpan =
  struct
    new : ticks:int64 -> TimeSpan + 3 overloads
    member Add : ts:TimeSpan -> TimeSpan
    member CompareTo : value:obj -> int + 1 overload
    member Days : int
    member Duration : unit -> TimeSpan
    member Equals : value:obj -> bool + 1 overload
    member GetHashCode : unit -> int
    member Hours : int
    member Milliseconds : int
    member Minutes : int
    ...
  end

Full name: System.TimeSpan

--------------------
System.TimeSpan()
System.TimeSpan(ticks: int64) : unit
System.TimeSpan(hours: int, minutes: int, seconds: int) : unit
System.TimeSpan(days: int, hours: int, minutes: int, seconds: int) : unit
System.TimeSpan(days: int, hours: int, minutes: int, seconds: int, milliseconds: int) : unit
field System.TimeSpan.Zero
property System.DateTime.UtcNow: System.DateTime
System.DateTime.ToString() : string
System.DateTime.ToString(provider: System.IFormatProvider) : string
System.DateTime.ToString(format: string) : string
System.DateTime.ToString(format: string, provider: System.IFormatProvider) : string
System.TimeSpan.ToString() : string
System.TimeSpan.ToString(format: string) : string
System.TimeSpan.ToString(format: string, formatProvider: System.IFormatProvider) : string
Raw view New version

More information

Link:http://fssnip.net/4O
Posted:6 years ago
Author:Tuomas Hietanen
Tags: datetime , timestamp