Skip to content

Instantly share code, notes, and snippets.

@chrislawlor
Created December 19, 2012 01:18
Show Gist options
  • Save chrislawlor/4333624 to your computer and use it in GitHub Desktop.
Save chrislawlor/4333624 to your computer and use it in GitHub Desktop.
No more looking this up every time I need to post Date / Time data to a Django-powered API
Date.prototype.toDjangoString = function() {
// YYYY-MM-DD HH:MM:SS
return this.getFullYear() + '-' +
(this.getMonth() + 1) + "-" +
this.getDate() + " " +
this.getHours() + ":" +
this.getMinutes() + ":" +
this.getSeconds();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment