util.js 367 B

1234567891011121314151617181920
  1. function pad(num) {
  2. if(num < 10) {
  3. return '0'+num;
  4. }
  5. else {
  6. return ''+num;
  7. }
  8. }
  9. function dateToString(date) {
  10. var dateString =
  11. date.getFullYear()+'/'+pad(1+date.getMonth())+'/'+ pad(date.getDate())+
  12. ' '+
  13. pad(date.getHours())+':'+pad(date.getMinutes());
  14. return dateString;
  15. }
  16. module.exports = {
  17. dateToString: dateToString
  18. }