JavaScript - MySQL Timestamp


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /**
  2.  * I make a mysql date timestamp
  3.  * @deprecated - Datepicker used instead
  4.  * @param {Object} dateobj - a date
  5.  */
  6. function jps_makeTimestamp( dateobj )
  7. {
  8. var date = new Date( dateobj );
  9. var yyyy = date.getFullYear();
  10. var mm = date.getMonth() + 1;
  11. var dd = date.getDate();
  12. var hh = date.getHours();
  13. var min = date.getMinutes();
  14. var ss = date.getSeconds();
  15.  
  16. var mysqlDateTime = yyyy + '-' + mm + '-' + dd + ' ' + hh + ':' + min + ':' + ss;
  17.  
  18. return mysqlDateTime;
  19. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.