NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 2 3 4 5 … 93 Next »
How to convert the startTIme value in json response?

 
  • 1 Vote(s) - 5 Average
How to convert the startTIme value in json response?
JavaWiz
Offline

Posting Freak

Jacksonville, FL. USA
Posts: 2,522
Threads: 141
Joined: Dec 2006
#1
2020-04-24, 11:54 PM
The xml output of NScriptHelper is not working for me for batch files, so I thought I'd write my own helper (in Python) for the few commands I need.  I've got it working, initiate a session, login (thanks to Martins example).  However I'm confused as to what format the startTime field is in so I can convert it to a printable date.

The call:  http://localhost:8866/service?method=rec...er=pending...

output snippet:

        {'id': 1648, 
            'name': 'The Blacklist', 
            'desc': 'Liz and the task force take on a cold case that may be linked to some new victims; Red tries to help a friend of Dembe who is in danger.', 
            'subtitle': 'Nyle Hatcher', 
            'startTime': 1587772800, 
            'duration': 3600, 

What is 1587772800?  How do I convert that to a date/time?  In the NScriptHelper xml, that translates to 4/24/2020 8:00:00 PM...
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,807
Threads: 769
Joined: Nov 2003
#2
2020-04-25, 12:20 AM
It's unix time, so number of seconds that have elapsed since January 1, 1970.
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,807
Threads: 769
Joined: Nov 2003
#3
2020-04-25, 12:22 AM
A quick google will show lots of ways to convert between this and datetime. For example:

Code:
public static DateTime FromUnixTime(long unixTime)
{
    return epoch.AddSeconds(unixTime);
}
private static readonly DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
JavaWiz
Offline

Posting Freak

Jacksonville, FL. USA
Posts: 2,522
Threads: 141
Joined: Dec 2006
#4
2020-04-25, 12:35 AM
(2020-04-25, 12:20 AM)sub Wrote: It's unix time, so number of seconds that have elapsed since January 1, 1970.
Ah, ok, got it, thanks!
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  NEWA JSON API oddity bgowland 3 2,835 2015-03-25, 03:23 AM
Last Post: bgowland
  <StartTime> and <EndTime> time formats? spinnaker 3 2,569 2013-10-25, 01:48 AM
Last Post: spinnaker
  Newtonsoft.Json mvallevand 9 4,243 2013-08-15, 05:10 PM
Last Post: whurlston
  How to convert special characters to use for a URL bgowland 2 1,600 2012-01-21, 05:35 PM
Last Post: bgowland
  Using JSON with C# bgowland 3 4,064 2011-06-29, 01:48 AM
Last Post: whurlston

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode