### Convert UNIX Timestamp

Helper Sub to convert a UNIX Timestamp to date & time.
Example TinkerForge MQTT message in JSON Format with timestamp from a RGB LED Bricklet.
tinkerforge/bricklet/rgb_led/zJW/rgb_value={"r":0,"_timestamp":1474553572.646973,"b":0,"g":0}
' Convert a UNIX timestamp, like 1474553572.646973 into format dd-MMM-YYYY HH:mm
`Sub ConvertUNIXTimeStamp(Value As String) As String
Dim TimeStamp As Long = Value * 1000
'Set the dateformat
DateTime.DateFormat = "dd-MMM-YYYY"
DateTime.TimeFormat = "HH:mm"
'Convert Date & Time to string
Return DateTime.Date(TimeStamp) & " " & DateTime.Time(TimeStamp)
End Sub`
The TinkerForge MQTT message JSON Format can be parsed using the JSON library.
For above example:
' {"r":0,"_timestamp":1474553572.646973,"b":0,"g":0}
Dim parser As JSONParser
parser.Initialize("{"r":0,"_timestamp":1474553572.646973,"b":0,"g":0}")
Dim root As Map = parser.NextObject
Dim r As Int = root.Get("r")
Dim b As Int = root.Get("b")
Dim g As Int = root.Get("g")
Dim _timestamp As Double = root.Get("_timestamp")

Changed: , Category: TinkerForge MQTT, File: T6C266M1977.htm, ID: 1977