Ok this is a strange one. Im trying to convert Start and Stop Times from an XMLTV file to Epoch so I can actually parse and use it.
So my goal is to convert the 2 times to Epoch and see if the Current time is either Exactly the Start or Stop time or Inbetween them. Obviously a time string like: 20160421112000 +0100 isnt going to work to check that way but if I could convert it to Epoch it would be Parsable.
The Start and Stop Time's are saved as a String. So how would I manage to convert it to Epoch if I cant even convert it to a Normal DateTime?
Sorry if this is a Noob question I dont normally work with DateTime functions so its quite new to me.
Example Times: Start - 20160421112000 +0100 End - 20160421113500 +0100
EDIT:
Thanks to Plutonix I got it to "work" somewhat. I still have a few issues with it that I have been googling a fix for ages but cant find one working.
This is my current code:
Dim CurrentTime As String = (Date.Now.ToUniversalTime - New DateTime(1970, 1, 1)).TotalMilliseconds
Dim StartTime As String = DateTimeOffset.ParseExact(c.StartTime.ToString, "yyyyMMddHHmmss zzz", New CultureInfo("en-UK")).ToUniversalTime.ToUnixTimeMilliseconds
Dim EndTime As String = DateTimeOffset.ParseExact(c.EndTime.ToString, "yyyyMMddHHmmss zzz", New CultureInfo("en-UK")).ToUniversalTime.ToUnixTimeMilliseconds
If CurrentTime >= StartTime And CurrentTime <= EndTime Then
'Console.WriteLine(New DateTime(1970, 1, 1).AddSeconds(c.StartTime.ToString).ToLocalTime)
OnNow.Text = c.Programme.ToString
StartToEndTime.Text = c.StartTime.ToString
End If
EDIT: Fixed the whole DST issue.
My other issue is that im now trying to use .AddSeconds to convert the Epoch time to a properly Formatted "TIME" I want it to display for example, 8:16pm no +0100 no year month day etc just the Time and PM how can I do that as it keeps saying the value is too big or something like that.