js long 날짜 형식 을 표준 날짜 형식 으로 변환 하 는 방법
                                            
 12050 단어  long
                    
코드 를 직접 올 리 면 여러분 에 게 도움 이 되 기 를 바 랍 니 다. (또한, 본인 은 최근 며칠 동안 MVC 4.0 + WCF + EF + Bootstrap 의 구조 시리즈 박문 을 만 들 기 시 작 했 습 니 다. 여러분 의 지지 와 지적 을 바 랍 니 다)
 3 <script language="javascript">
 4 //  Date format  
 5 Date.prototype.format = function (format) {
 6 var o = {
 7 "M+": this.getMonth() + 1,
 8 "d+": this.getDate(),
 9 "h+": this.getHours(),
10 "m+": this.getMinutes(),
11 "s+": this.getSeconds(),
12 "q+": Math.floor((this.getMonth() + 3) / 3),
13 "S": this.getMilliseconds()
14 }
15 if (/(y+)/.test(format)) {
16 format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
17 }
18 for (var k in o) {
19 if (new RegExp("(" + k + ")").test(format)) {
20 format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
21 }
22 }
23 return format;
24 }
25 /**
26 *            
27 * @param date     
28 * @param isFull           ,
29 *  true ,    "2013-12-06 01:05:04"
30 *  false ,     "2013-12-06"
31 * @return           
32 */
33 function getSmpFormatDate(date, isFull) {
34 var pattern = "";
35 if (isFull == true || isFull == undefined) {
36 pattern = "yyyy-MM-dd hh:mm:ss";
37 } else {
38 pattern = "yyyy-MM-dd";
39 }
40 return getFormatDate(date, pattern);
41 }
42 /**
43 *              
44 * @param date     
45 * @param isFull           ,
46 *  true ,    "2013-12-06 01:05:04"
47 *  false ,     "2013-12-06"
48 * @return           
49 */
50 function getSmpFormatNowDate(isFull) {
51 return getSmpFormatDate(new Date(), isFull);
52 }
53 /**
54 *  long       
55 * @param l long 
56 * @param isFull           ,
57 *  true ,    "2013-12-06 01:05:04"
58 *  false ,     "2013-12-06"
59 * @return           
60 */
61 function getSmpFormatDateByLong(l, isFull) {
62 return getSmpFormatDate(new Date(l), isFull);
63 }
64 /**
65 *  long       
66 * @param l long 
67 * @param pattern      ,  :yyyy-MM-dd hh:mm:ss
68 * @return           
69 */
70 function getFormatDateByLong(l, pattern) {
71 return getFormatDate(new Date(l), pattern);
72 }
73 /**
74 *            
75 * @param l long 
76 * @param pattern      ,  :yyyy-MM-dd hh:mm:ss
77 * @return           
78 */
79 function getFormatDate(date, pattern) {
80 if (date == undefined) {
81 date = new Date();
82 }
83 if (pattern == undefined) {
84 pattern = "yyyy-MM-dd hh:mm:ss";
85 }
86 return date.format(pattern);
87 }
88 //alert(getSmpFormatDate(new Date(1279849429000), true));
89 //alert(getSmpFormatDate(new Date(1279849429000),false));
90 //alert(getSmpFormatDateByLong(1279829423000, true));
91 alert(getSmpFormatDateByLong(1279829423000,false));
92 //alert(getFormatDateByLong(1279829423000, "yyyy-MM"));
93 //alert(getFormatDate(new Date(1279829423000), "yy-MM"));
94 //alert(getFormatDateByLong(1279849429000, "yyyy-MM hh:mm"));
95 </script> 이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
java int 바이트와 롱바이트 돌리는 방법네트워크 프로그래밍에서, 대역폭이나 인코딩을 절약하기 위해서, 일반적으로string으로 전환하는 것이 아니라long과 int를 원생 방식으로 처리해야 한다. 지금까지 여러분께 자바 int로 바이트와 롱으로 바이트를 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.