What type should i use to store time length with MongoDB?
I need to store time length of sound data. so Timestamp type doesn’t seem right.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
You should use an integer for that.
MongoDB has two data types especially for timekeeping: Date and Timestamp. But these are meant to represent a specific point in time. They aren’t suitable for expressing durations (also, timestamp is for internal use. Users are discouraged from using it).
So your best bet is to convert the duration into milliseconds and store this value in the database.