Skip to content

Instantly share code, notes, and snippets.

@k-k
Created June 12, 2013 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k-k/5767808 to your computer and use it in GitHub Desktop.
Save k-k/5767808 to your computer and use it in GitHub Desktop.
Creates a linux command to quickly convert a date time string into an ObjectId string.
#!/usr/bin/env php
<?php
echo str_pad( dechex( strtotime( $argv[1] ) ), 8, "0", STR_PAD_LEFT ) . "0000000000000000\n";
@k-k
Copy link
Author

k-k commented Jun 12, 2013

Taken from Kristina Chodrow's answer on Stackoverflow.

Allows me to quickly create timestamp based ObjectIds for querying on the console. Just make executable and copy to /usr/bin/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment