0

can i get help coverting this string to date format.

Here is the JSon name and value

notBefore: 1413936000000
notAfter: 1479427199000

I believe this needs to be converted to US format date mm/dd/yyyy

The callback string looks like this:

response.endpoints[0].details.cert.notBefore
response.endpoints[0].details.cert.notAfter
scniro
  • 16,844
  • 8
  • 62
  • 106
user3436467
  • 1,763
  • 1
  • 22
  • 35

1 Answers1

3

Just go ahead and craft up a new Date

new Date(notBefore)

If your values are indeed strings, you can parseInt() them

JSFiddle Example

If you need a simple example for mm/dd/yyyy format, here is a working fiddle to get you up and running.

var notBefore = 1413936000000;
var date = new Date(notBefore);
var formattedDate = (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear();

With Basic Format JSFiddle

scniro
  • 16,844
  • 8
  • 62
  • 106
  • the value is within json data so I have to reference it but i get Nan/Nan/Nan var notbefore = response.endpoints[0].details.cert.notBefore var date = new Date(notBefore) var formattedDate = (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear() – user3436467 Apr 09 '15 at 13:12
  • Is it a `typeof` string? As I pointed out in the answer, you may need to `parseInt()` the value first – scniro Apr 09 '15 at 13:13
  • per your advice it worked like this: var date = new Date(parseInt(response.endpoints[0].details.cert.notBefore)) – user3436467 Apr 09 '15 at 13:20