Skip to content

Instantly share code, notes, and snippets.

@onel0p3z
Created August 19, 2013 20:28
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 onel0p3z/6273719 to your computer and use it in GitHub Desktop.
Save onel0p3z/6273719 to your computer and use it in GitHub Desktop.
Date helpers functions
function SendDate(date){
// Expecting date as string like '2013-08-08'
var temp;
date = date.split('-');
temp = new Date(date);
// Returns '2013-08-19T04:00:00.000Z'
return temp.toISOString();
}
function ReceiveDate(date){
// Expecting date like ISODate('2013-08-19T04:00:00.000Z')
var temp;
date = new Date(date);
temp = date.getFullYear()+''+(date.getMonth()+1)+''+date.getDate();
// Returns '2013-08-19'
return temp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment