복붙노트

[JQUERY] 날짜로 밀리 초 변환 (jQuery를 / 자바 스크립트)

JQUERY

날짜로 밀리 초 변환 (jQuery를 / 자바 스크립트)

해결법


  1. 1.VAR 시간은 새로운 날짜 () = 다음 getTime ()를.; VAR 날짜는 새 날짜 (시간) =; 경고 (date.toString ()); // 수요일 2011년 1월 12일 그리니치 표준시 12시 42분 46초-0800 (PST)

    VAR 시간은 새로운 날짜 () = 다음 getTime ()를.; VAR 날짜는 새 날짜 (시간) =; 경고 (date.toString ()); // 수요일 2011년 1월 12일 그리니치 표준시 12시 42분 46초-0800 (PST)


  2. 2.사용자 정의 날짜 서식 원한다면 나는 그것을위한 간단한 기능을 제공합니다 :

    사용자 정의 날짜 서식 원한다면 나는 그것을위한 간단한 기능을 제공합니다 :

    var now = new Date;
    console.log( now.customFormat( "#DD#/#MM#/#YYYY# #hh#:#mm#:#ss#" ) );
    

    여기에 지원되는 토큰은 다음과 같습니다 :

    token:     description:             example:
    #YYYY#     4-digit year             1999
    #YY#       2-digit year             99
    #MMMM#     full month name          February
    #MMM#      3-letter month name      Feb
    #MM#       2-digit month number     02
    #M#        month number             2
    #DDDD#     full weekday name        Wednesday
    #DDD#      3-letter weekday name    Wed
    #DD#       2-digit day number       09
    #D#        day number               9
    #th#       day ordinal suffix       nd
    #hhhh#     2-digit 24-based hour    17
    #hhh#      military/24-based hour   17
    #hh#       2-digit hour             05
    #h#        hour                     5
    #mm#       2-digit minute           07
    #m#        minute                   7
    #ss#       2-digit second           09
    #s#        second                   9
    #ampm#     "am" or "pm"             pm
    #AMPM#     "AM" or "PM"             PM
    

    그리고 여기 코드는 :

    //*** This code is copyright 2002-2016 by Gavin Kistner, !@phrogz.net
    //*** It is covered under the license viewable at http://phrogz.net/JS/_ReuseLicense.txt
    Date.prototype.customFormat = function(formatString){
      var YYYY,YY,MMMM,MMM,MM,M,DDDD,DDD,DD,D,hhhh,hhh,hh,h,mm,m,ss,s,ampm,AMPM,dMod,th;
      YY = ((YYYY=this.getFullYear())+"").slice(-2);
      MM = (M=this.getMonth()+1)<10?('0'+M):M;
      MMM = (MMMM=["January","February","March","April","May","June","July","August","September","October","November","December"][M-1]).substring(0,3);
      DD = (D=this.getDate())<10?('0'+D):D;
      DDD = (DDDD=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][this.getDay()]).substring(0,3);
      th=(D>=10&&D<=20)?'th':((dMod=D%10)==1)?'st':(dMod==2)?'nd':(dMod==3)?'rd':'th';
      formatString = formatString.replace("#YYYY#",YYYY).replace("#YY#",YY).replace("#MMMM#",MMMM).replace("#MMM#",MMM).replace("#MM#",MM).replace("#M#",M).replace("#DDDD#",DDDD).replace("#DDD#",DDD).replace("#DD#",DD).replace("#D#",D).replace("#th#",th);
      h=(hhh=this.getHours());
      if (h==0) h=24;
      if (h>12) h-=12;
      hh = h<10?('0'+h):h;
      hhhh = hhh<10?('0'+hhh):hhh;
      AMPM=(ampm=hhh<12?'am':'pm').toUpperCase();
      mm=(m=this.getMinutes())<10?('0'+m):m;
      ss=(s=this.getSeconds())<10?('0'+s):s;
      return formatString.replace("#hhhh#",hhhh).replace("#hhh#",hhh).replace("#hh#",hh).replace("#h#",h).replace("#mm#",mm).replace("#m#",m).replace("#ss#",ss).replace("#s#",s).replace("#ampm#",ampm).replace("#AMPM#",AMPM);
    };
    

  3. 3.할 수 있습니다 단순히 미 Datejs의 원하는 형식으로 날짜를 변환하기 위해 라이브러리입니다.

    할 수 있습니다 단순히 미 Datejs의 원하는 형식으로 날짜를 변환하기 위해 라이브러리입니다.

    나는 시험의 커플을 실행했습니다 그것은 작동합니다.

    다음은 그것을 달성하는 방법을 설명하는 조각이다 :

    var d = new Date(1469433907836);
    
    d.toLocaleString(); // expected output: "7/25/2016, 1:35:07 PM"
    
    d.toLocaleDateString(); // expected output: "7/25/2016"
    
    d.toDateString();  // expected output: "Mon Jul 25 2016"
    
    d.toTimeString(); // expected output: "13:35:07 GMT+0530 (India Standard Time)"
    
    d.toLocaleTimeString(); // expected output: "1:35:07 PM"
    

  4. 4.다음은 바람직한 출력 날짜 형식을 가능하게하는 조각이다 :

    다음은 바람직한 출력 날짜 형식을 가능하게하는 조각이다 :

    var time = new Date();
    var time = time.getTime();
    
    var theyear = time.getFullYear();
    var themonth = time.getMonth() + 1;
    var thetoday = time.getDate();
    
    document.write("The date is: ");
    document.write(theyear + "/" + themonth + "/" + thetoday);
    

  5. 5.이 코드를 사용해보십시오 :

    이 코드를 사용해보십시오 :

    var datetime = 1383066000000; // anything
    var date = new Date(datetime);
    var options = {
            year: 'numeric', month: 'numeric', day: 'numeric',
        };
    
    var result = date.toLocaleDateString('en', options); // 10/29/2013
    

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString : 더보기


  6. 6.이 코드를 사용해보십시오 :

    이 코드를 사용해보십시오 :

    var milisegundos = parseInt(data.replace("/Date(", "").replace(")/", ""));
    var newDate = new Date(milisegundos).toLocaleDateString("en-UE");
    

    그것을 즐기십시오!


  7. 7.이걸로 해봐 :

    이걸로 해봐 :

    var time = new Date().toJSON();
    

  8. 8.한 줄의 코드입니다.

    한 줄의 코드입니다.

    var date = new Date(new Date().getTime());
    

    또는

    var date = new Date(1584120305684);
    

  9. 9.

    /Date(1383066000000)/
    
    function convertDate(data) {
        var getdate = parseInt(data.replace("/Date(", "").replace(")/", ""));
        var ConvDate= new Date(getdate);
        return ConvDate.getDate() + "/" + ConvDate.getMonth() + "/" + ConvDate.getFullYear();
    }
    

  10. 10.밀리 초 날짜는 1526813885836입니다 당신이 샘플 코드를 문자열로 날짜를 액세스 할 수 있도록 날짜를 가정합니다 :

    밀리 초 날짜는 1526813885836입니다 당신이 샘플 코드를 문자열로 날짜를 액세스 할 수 있도록 날짜를 가정합니다 :

    console.log(new Date(1526813885836).toString());
    

    선명도에 대한 코드는 아래를 참조 :

    const theTime = new Date(1526813885836);
    console.log(theTime.toString());
    

  11. 11.사용 datejs

    사용 datejs

    new Date().toString('yyyy-MM-d-h-mm-ss');
    
  12. from https://stackoverflow.com/questions/4673527/converting-milliseconds-to-a-date-jquery-javascript by cc-by-sa and MIT license