Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6967525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:20:00+00:00 2026-05-27T16:20:00+00:00

I am using Node.js and tried to store the timestamp data in the Mongodb

  • 0

I am using Node.js and tried to store the timestamp data in the Mongodb Database with the folowing code:

`articleProvider.saveUser({
        userID : user,
        email : email,
        address : "",
        time : new Date().getTime(),
        },function(error,userData){
                if(!userData){ callback(error);}
                else{ callback(null,userData);}
            });
        }
    });`

And the data stored in the Database is (from mongo shell):

{ "userID" : "hem", "email" : "hereshem@gmail.com", "address" : "Kathmandu", "time" : NumberLong("1320911838254"), "_id" : ObjectId("4ebb83dea7dd40990e000002") }

BUT if I retrieve the data in node.js console the output becomes :

{ userID: 'hem',
  email: 'hereshem@gmail.com',
  address: 'Kathmandu',
  time: { low_: -1938088914, high_: 307 },
  _id: 4ebb83dea7dd40990e000002 }

Now My Question is How to Retrieve this value of field “time” with NumberLong data?

It gives the output with two different fields of “low_” and “high_”. But, I want the output only “1320911838254” .

Can Anyone Help me?


Thanks for the response. But I tried to get the number using

var value = new Long(low_bits, high_bits).toNumber();

as Mr. Lycha had posted, but in Node.js Platform it shows an error “Long is not defined” as :

var value = new Long(user.time.low_, user.time.high_).toNumber();
ReferenceError: Long is not defined
at /home/developer/Desktop/Express/app.js:65:1
at /home/developer/Desktop/Express/public/js/processData.js:76:10
at /home/developer/Desktop/Express/public/js/dbQuery.js:196:16
at [object Object].<anonymous> (/home/developer/node_modules/mongodb/lib/mongodb/collection.js:743:5)
at [object Object].emit (events.js:67:17)
at [object Object].<anonymous> (/home/developer/node_modules/mongodb/lib/mongodb/connections/server.js:97:12)
at [object Object].emit (events.js:64:17)
at Socket.<anonymous> (/home/developer/node_modules/mongodb/lib/mongodb/connection.js:161:16)
at Socket.emit (events.js:64:17)
at Socket._onReadable (net.js:678:14)

How to get the long parser in node.js? Any Idea?

And thanks strada for response. But how to store as dateObject in Mongodb?
The DataType is itself defined. Is there any method to change the Datatype in Mongodb?
And How to Parse it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:20:00+00:00Added an answer on May 27, 2026 at 4:20 pm

    I have found the best solution after the long practice :

    articleProvider.saveUser({
        userID : user,
        email : email,
        address : "",
        time : new Date().getTime().toString(),
        },function(error,userData){
                if(!userData){ callback(error);}
                else{ callback(null,userData);}
            });
        }
    });
    

    Store the date object as the string object using “toString()” and after the query change the string object into the integer value using “parseInt()”.

    I think this is really easy and good solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Node.js app using Express that stores data in a mongoDB (locally).
I tried connecting to my cassandra cluster [version 1.0.6] via nodejs using node-cassandra-client This
I need to store a tree data structure in my database, for which I
I've written a web-server using Node.js. When I tried to test my server with
I'm interested in using Node.js as a socket server for stream-based communication with tens
I'm trying to evaluate an xml node using xpath and i'm not sure why
I'm attempting to check for the existence of a node using the following .NET
Anyone know how to get the position of a node using XPath? Say I
I try to set an attribute in a XML node using MSXML. IXMLDOMElement alone
How can one select a specific sibling of a context node using jQuery? Specifically,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.