Some encoding methods, whether automated or manual, choose to store dates in a format that uses a Unix timestamp to indicate when the data was last updated.
To extract a Date
object from this format, you will need to extract the numerical values from the string and pass them into the Date()
constructor.
var dateStr = obj.UpdatedDate;
var dateInfo = dateStr.match(/\/Date\((\d+)\)\//);
var update = new Date(parseInt(dateInfo[1], 10));
If you want to check if the update occurred within the past 20 seconds, simply calculate the difference between this date object and a new one representing the current time.
var diff = Date.now() - update; // The result is in milliseconds
var diffSec = diff/1000; // Convert it to seconds