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 7855789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:29:35+00:00 2026-06-02T20:29:35+00:00

I use my document _id client-side as strings. I would love to be able

  • 0

I use my document _id client-side as strings. I would love to be able pull the timestamp from this value as you can on the server. Is it possible to recreate this functionality on the client side? (recast as objectid, or create a standalone function to pull this data)

example _id: "4f94c2a11a6bbec3872cb315"

Thanks!

  • 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-06-02T20:29:37+00:00Added an answer on June 2, 2026 at 8:29 pm

    How about this, broken down into steps… unfortunately it’s only second resolution time that gets stored in the ObjectID.

    var id = "4f94c2a11a6bbec3872cb315"​;
    // first 4 bytes are the timestamp portion (8 hex chars)
    var timehex = id.sub​string(0,8);
    console.log(timehex); // gives: 4f94c2a1
    
    // convert to a number... base 16
    var secondsSinceEpoch = parseInt(timehex, 16);
    console.log(secondsSinceEpoch); // gives: 1335149217
    
    // convert to milliseconds, and create a new date
    var dt = new Date(secondsSinceEpoch*1000);
    console.log(dt);​ // gives: Sun Apr 22 2012 22:46:57 GMT-0400 (EDT)
    

    See jsfiddle if you want to test: http://jsfiddle.net/pZdyM/

    NOTE: this is kind of kludgy–it depends on the current ObjectID format. They might move the timestamp around within the ObjectID one day, and that would break this.

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

Sidebar

Related Questions

Can someone explain to me why I cannot use document.getElementById('id').value inside of a function?
this is my first time trying to use document classes in AS3 and im
The logged value is shown below: but why when I use document.write or alert
I'm starting with socket.io with a simple exemple : Client Side : $(document).ready(function ()
When I use embedded javascript functions I can get client id of elements with
I'd like to create a Word document using Python, however, I want to re-use
As documented here: http://www.jblotus.com/2011/05/24/keeping-your-handlebars-js-templates-organized/ I am trying to use this function: ( function getTemplateAjax(path,
For example, when I use cursor.execute() as documented : >>> from django.db import connection
When should you use document.all vs. document.getElementById ?
Possible Duplicate: Why use document.write? Considering the negative effects of document.write(), why are most

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.