Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #29376
    jic
    Participant

    Greetings.

    I would like to change the format of Insert/Date Time SHIFT-F5 menu to produce the YYYY-MM-DD HH:MM:SS.mmm instead of the default. Is this a possibility? Thanks.

    josé

    #29377
    Patrick C
    Participant

    I’ve got an old script that gets close, perhaps it helps.

    // Inspired by & resources
    //   https://www.emeditor.com/forums/topic/option-to-adjust-the-datetime-format-edit-insert-time-and-date/
    //   https://www.emeditor.com/forums/topic/insert-long-date/
    //   https://www.w3schools.com/jsref/jsref_tolocaledatestring.asp  +  jsref_getmonth.asp  + jsref_getdate.asp
    
    function return_date_long_time() {
      var date = new Date();
      // var n = d.toLocaleDateString();   // old approach - unreliable
    
      // Date assembly
      var dd   = date.getDate();           // returns the day of the month (from 1 to 31)
      if( dd < 10 )  dd = "0" + dd;
    
      var MM   = date.getMonth() + 1;      // returns the month (from 0 to 11)!
      if( MM < 10 )  MM = "0" + MM;
    
      var yyyy = date.getFullYear();       // Returns the year (4 digits)
    
      // time assembly
      var hh = date.getHours();            // Returns the hour (from 0-23)
      if( hh < 10 )  hh = "0" + hh;
      var mm = date.getMinutes();          // Returns the minutes (from 0-59)
      if( mm < 10 )  mm = "0" + mm;
      var ss = date.getSeconds();          // Returns the seconds (from 0-59)
      if( ss < 10 )  ss = "0" + ss;
    
      // “Output”
      return( yyyy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss );
    }
    
    document.write( return_date_long_time() );
    #29378
    jic
    Participant

    Thanks, Patrick. That is what I am doing now: Using a script to make it what I want. But, it would be nice if EmEditor would have an option to format the output to a desirable date, time or date+ time formats. Thanks, though.

    #29382
    Yutaka Emura
    Keymaster

    You can use the “Date and Time” command instead of the “Time and Date” command, and set the date/time format in the Format page of the Customize dialog box.

    #29384
    jic
    Participant

    Thanks. That is exactly what I was looking for.

    #29386
    jic
    Participant

    By the way, this is the option I chose: yyyy-MM-dd HH:mm:ss.ms which provides exactly what I want: 2023-09-08 07:54:27.5427

    thanks.

    #29591
    jic
    Participant

    Sorry to bring this up again, but is there a way to bring the milliseconds in the Format page of the Customize dialog box? I tried ms but tat brings minus and seconds and puts them together.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.