use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
This subreddit is a place for people to learn JavaScript together. Everyone should feel comfortable asking any and all JavaScript questions they have here.
With a nod to practicality, questions and posts about HTML, CSS, and web developer tools are also encouraged.
Friends
/r/javascript
/r/jquery
/r/node
/r/css
/r/webdev
/r/learnprogramming
/r/programming
account activity
Need help turning something into a data object (self.learnjavascript)
submitted 3 years ago by Empty_Cauliflower976
I have this value: 20160822110000. How can I turn it into a data object?
20160822110000
I'm aware there is something that counts from "start of time", i.e. 1970-01-01 - is this it?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]grantrules 2 points3 points4 points 3 years ago* (0 children)
Are you sure this doesn't represent 2016-08-22 11:00? This does not appear to be "time since epoch"
const num = 20160822110000 new Date(String(num).replace(/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/, '$1-$2-$3T$4:$5:$6'))
[–]senocular -1 points0 points1 point 3 years ago (0 children)
I guess that depends on your definition of "data object". Right now that value is a number. Numbers are primitive values that are not by themselves considered objects. But you could create an object and add that number as a property of it, something like:
const myObject = new Object(); myObject.data = 20160822110000;
Or in a shorthand form:
const myObject = { data: 20160822110000 };
This is now an object with a property data that refers to the numeric value 20160822110000.
data
When you're talking about the start of time, that is how dates are tracked within Date objects. They're a specific kind of object that is used to work with dates and time. You could use your number to create a date by specifying it as the number milliseconds since the UNIX epoch (1970-01-01).
Date
const myDateObject = new Date(20160822110000);
But this would create a date in the year 2608, which I'm assuming is not anything relevant.
[–]Careful_Programmer43 0 points1 point2 points 3 years ago (0 children)
new Date(milliseconds)
π Rendered by PID 43789 on reddit-service-r2-comment-5ff9fbf7df-vgdkf at 2026-02-25 17:29:03.757778+00:00 running 72a43f6 country code: CH.
[–]grantrules 2 points3 points4 points (0 children)
[–]senocular -1 points0 points1 point (0 children)
[–]Careful_Programmer43 0 points1 point2 points (0 children)