-
Notifications
You must be signed in to change notification settings - Fork 1
/
5b51f4b1.3a66cd40.js
1 lines (1 loc) · 4.09 KB
/
5b51f4b1.3a66cd40.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[32],{101:function(e,t,r){"use strict";r.r(t),r.d(t,"frontMatter",(function(){return o})),r.d(t,"metadata",(function(){return c})),r.d(t,"rightToc",(function(){return p})),r.d(t,"default",(function(){return u}));var n=r(3),a=r(7),i=(r(0),r(159)),o={slug:"javascript-utils",title:"javascript \u5de5\u5177\u51fd\u6570",tags:["javascript","utils"]},c={permalink:"/javascript-utils",source:"@site/blog/2017-01-20-javascript-utils.md",description:"\u65f6\u95f4\u6233\u8f6c\u6362\u4e3a YY-MM-DD hhss \u5b57\u7b26\u4e32\u683c\u5f0f",date:"2017-01-20T00:00:00.000Z",tags:[{label:"javascript",permalink:"/tags/javascript"},{label:"utils",permalink:"/tags/utils"}],title:"javascript \u5de5\u5177\u51fd\u6570",readingTime:5.42,truncated:!0,prevItem:{title:"\u79fb\u52a8\u7aef\u81ea\u9002\u5e94\u89e3\u51b3\u65b9\u6848",permalink:"/mobile-responsive-solution"},nextItem:{title:"React \u5b66\u4e60\u7b14\u8bb0",permalink:"/react-tutorial"}},p=[],m={rightToc:p};function u(e){var t=e.components,r=Object(a.a)(e,["components"]);return Object(i.b)("wrapper",Object(n.a)({},m,r,{components:t,mdxType:"MDXLayout"}),Object(i.b)("h4",{id:"\u65f6\u95f4\u6233\u8f6c\u6362\u4e3a-yy-mm-dd-hhmmss-\u5b57\u7b26\u4e32\u683c\u5f0f"},"\u65f6\u95f4\u6233\u8f6c\u6362\u4e3a YY-MM-DD hh:mm:ss \u5b57\u7b26\u4e32\u683c\u5f0f"),Object(i.b)("pre",null,Object(i.b)("code",Object(n.a)({parentName:"pre"},{className:"language-javascript"}),"timeFormat(timestamp) {\n //timestamp\u662f\u6574\u6570\uff0c\u5426\u5219\u8981parseInt\u8f6c\u6362\n var time = new Date(timestamp);\n var y = time.getFullYear();\n var m = time.getMonth() + 1;\n var d = time.getDate();\n var h = time.getHours();\n var mm = time.getMinutes();\n var s = time.getSeconds();\n return y + '-' + add02Time(m) + '-' + add02Time(d) + ' ' +add02Time(h) + ':' +add02Time(mm) + ':' + add02Time(s);\n};\nadd02Time(m) {\n return m < 10 ? '0' + m : m\n},\n")))}u.isMDXComponent=!0},159:function(e,t,r){"use strict";r.d(t,"a",(function(){return l})),r.d(t,"b",(function(){return f}));var n=r(0),a=r.n(n);function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?o(Object(r),!0).forEach((function(t){i(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function p(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r,n,a={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}var m=a.a.createContext({}),u=function(e){var t=a.a.useContext(m),r=t;return e&&(r="function"==typeof e?e(t):c(c({},t),e)),r},l=function(e){var t=u(e.components);return a.a.createElement(m.Provider,{value:t},e.children)},s={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},d=a.a.forwardRef((function(e,t){var r=e.components,n=e.mdxType,i=e.originalType,o=e.parentName,m=p(e,["components","mdxType","originalType","parentName"]),l=u(r),d=n,f=l["".concat(o,".").concat(d)]||l[d]||s[d]||i;return r?a.a.createElement(f,c(c({ref:t},m),{},{components:r})):a.a.createElement(f,c({ref:t},m))}));function f(e,t){var r=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var i=r.length,o=new Array(i);o[0]=d;var c={};for(var p in t)hasOwnProperty.call(t,p)&&(c[p]=t[p]);c.originalType=e,c.mdxType="string"==typeof e?e:n,o[1]=c;for(var m=2;m<i;m++)o[m]=r[m];return a.a.createElement.apply(null,o)}return a.a.createElement.apply(null,r)}d.displayName="MDXCreateElement"}}]);