format.wxs 691 B

12345678910111213141516171819202122232425262728
  1. function formatDate(time) {
  2. var t = getDate(time);
  3. var tf = function (i) {
  4. return (i < 10 ? '0' : '') + i
  5. };
  6. var year = t.getFullYear();
  7. var month = tf(t.getMonth() + 1);
  8. var day = tf(t.getDate());
  9. var hour = tf(t.getHours());
  10. var minute = tf(t.getMinutes());
  11. return month + '-' + day + ' ' + hour + ':' + minute;
  12. }
  13. function getBirthday(birthday) {
  14. var t = getDate(birthday);
  15. var tf = function (i) {
  16. return (i < 10 ? '0' : '') + i
  17. };
  18. var year = t.getFullYear();
  19. var month = tf(t.getMonth() + 1);
  20. var day = tf(t.getDate());
  21. return year + '年' + month + '月' + day + '日';
  22. }
  23. module.exports = {
  24. formatDate: formatDate,
  25. getBirthday: getBirthday
  26. }