DateTimeOverFlowFormat.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. function changeDateFormate(time) {
  2. if (time == 0 || time == null || time == undefined)
  3. return "";
  4. if (time != null) {
  5. var date = new Date(parseInt(time.replace("/Date(", "").replace(")/", ""), 10));
  6. var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
  7. var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
  8. var str = date.getFullYear() + "-" + month + "-" + currentDate;
  9. return str;
  10. } else {
  11. return "";
  12. }
  13. }
  14. function changeDateFormate2(time) {
  15. if (time == 0 || time == null || time == undefined)
  16. return "";
  17. if (time != null) {
  18. var date = new Date(time);
  19. var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
  20. var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
  21. var str = date.getFullYear() + "-" + month + "-" + currentDate;
  22. return str;
  23. } else {
  24. return "";
  25. }
  26. }
  27. function changeDateTimeFormate2(time) {
  28. if (time == 0 || time == null || time == undefined)
  29. return "";
  30. if (time != null) {
  31. var date = new Date(time);
  32. var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
  33. var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
  34. var str = date.getFullYear() + "-" + month + "-" + currentDate + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
  35. //return str;
  36. return '<div title="' + str + '">' + str + '</div>';
  37. } else {
  38. return "";
  39. }
  40. }
  41. function changeDateTimeFormate(time) {
  42. if (time == 0 || time == null || time == undefined)
  43. return "";
  44. if (time != null) {
  45. var date = new Date(parseInt(time.replace("/Date(", "").replace(")/", ""), 10));
  46. var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
  47. var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
  48. var str = date.getFullYear() + "-" + month + "-" + currentDate + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
  49. //return str;
  50. return '<div title="' + str + '">' + str + '</div>';
  51. } else {
  52. return "";
  53. }
  54. }
  55. function getCurrentTime() {
  56. var date = new Date();
  57. var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
  58. var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
  59. var str = date.getFullYear() + "-" + month + "-" + currentDate + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
  60. return str;
  61. }
  62. function getTimeStr(date) {
  63. var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
  64. var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
  65. var str = date.getFullYear() + "-" + month + "-" + currentDate + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
  66. return str;
  67. }
  68. function changeIntToDateTime(time) {
  69. if (time == 0 || time == null || time == undefined)
  70. return "";
  71. if (time != null) {
  72. //return new Date(parseInt(time) * 1000).toLocaleString().replace(/:\d{1,2}$/, ' ');
  73. var date = new Date();
  74. date.setTime(time * 1000);
  75. var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
  76. var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
  77. var str = date.getFullYear() + "-" + month + "-" + currentDate + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
  78. //return str;
  79. return '<div title="' + str + '">' + str + '</div>';
  80. } else {
  81. return "";
  82. }
  83. }
  84. function formatContent(value, row) {
  85. if (value == null || value == undefined) {
  86. return '<div title=""></div>';
  87. }
  88. return '<div title="' + value + '">' + value + '</div>';
  89. }
  90. function formatDate(value, row) {
  91. var str = changeDateFormate(value);
  92. return '<div title="' + str + '">' + str + '</div>';
  93. }
  94. function formatDate2(value, row) {
  95. var str = changeDateFormate2(value);
  96. return '<div title="' + str + '">' + str + '</div>';
  97. }
  98. function formatDateTime(value, row) {
  99. var str = changeDateTimeFormate(value);
  100. return '<div title="' + str + '">' + str + '</div>';
  101. }