排队支付小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
1.8 KiB

  1. /* *
  2. * 把Long类型的1527672756454日期还原yyyy-MM-dd 00:00:00格式日期
  3. */
  4. function datetimeFormat(longTypeDate){
  5. var dateTypeDate = "";
  6. var date = new Date();
  7. date.setTime(longTypeDate);
  8. dateTypeDate += date.getFullYear(); //年
  9. dateTypeDate += "-" + getMonth(date); //月
  10. dateTypeDate += "-" + getDay(date); //日
  11. dateTypeDate += " " + getHours(date); //时
  12. dateTypeDate += ":" + getMinutes(date); //分
  13. dateTypeDate += ":" + getSeconds(date); //分
  14. return dateTypeDate;
  15. }
  16. /*
  17. * 时间格式化工具
  18. * 把Long类型的1527672756454日期还原yyyy-MM-dd格式日期
  19. */
  20. function dateFormat(longTypeDate){
  21. var dateTypeDate = "";
  22. var date = new Date();
  23. date.setTime(longTypeDate);
  24. dateTypeDate += date.getFullYear(); //年
  25. dateTypeDate += "-" + getMonth(date); //月
  26. dateTypeDate += "-" + getDay(date); //日
  27. return dateTypeDate;
  28. }
  29. //返回 01-12 的月份值
  30. function getMonth(date){
  31. var month = "";
  32. month = date.getMonth() + 1; //getMonth()得到的月份是0-11
  33. if(month<10){
  34. month = "0" + month;
  35. }
  36. return month;
  37. }
  38. //返回01-30的日期
  39. function getDay(date){
  40. var day = "";
  41. day = date.getDate();
  42. if(day<10){
  43. day = "0" + day;
  44. }
  45. return day;
  46. }
  47. //小时
  48. function getHours(date){
  49. var hours = "";
  50. hours = date.getHours();
  51. if(hours<10){
  52. hours = "0" + hours;
  53. }
  54. return hours;
  55. }
  56. //分
  57. function getMinutes(date){
  58. var minute = "";
  59. minute = date.getMinutes();
  60. if(minute<10){
  61. minute = "0" + minute;
  62. }
  63. return minute;
  64. }
  65. //秒
  66. function getSeconds(date){
  67. var second = "";
  68. second = date.getSeconds();
  69. if(second<10){
  70. second = "0" + second;
  71. }
  72. return second;
  73. }
  74. module.exports = {
  75. datetimeFormat: datetimeFormat,
  76. dateFormat: dateFormat,
  77. };