Tagged: insert date menu
- AuthorPosts
- September 5, 2023 at 6:48 am #29376
jic
ParticipantGreetings.
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é
September 5, 2023 at 7:36 am #29377Patrick C
ParticipantI’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() );
September 5, 2023 at 9:01 am #29378jic
ParticipantThanks, 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.
September 7, 2023 at 3:53 am #29382Yutaka Emura
KeymasterYou 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.
September 7, 2023 at 7:07 am #29384jic
ParticipantThanks. That is exactly what I was looking for.
September 8, 2023 at 4:56 am #29386jic
ParticipantBy 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.
November 28, 2023 at 10:00 am #29591jic
ParticipantSorry 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.
October 30, 2024 at 1:27 pm #30094J Melvin
ParticipantAlong the same lines, is there a way to add an automated macro or other technique to automatically update the date and time a document was edited, within the body of the document, in case a user forgets to press SHIFT-F5 .
October 31, 2024 at 2:05 pm #30095Yutaka Emura
KeymasterHow about the Notepad-Compatible Diary option (File page of configuration properties)?
December 14, 2024 at 4:20 pm #30134netsking
ParticipantDear Yutaka, That’s cool function. I am wondering if it is possible to customize the time-date in Notepad-Compatible Diary mode?
It uses system default format: time-date. I would like date-time.December 16, 2024 at 10:12 am #30135Yutaka Emura
KeymasterYou can easily do this with a macro. First, create a macro similar to the one below (based on Patrick C’s work) and save it under a name like “WriteDateTime.jsee”.
Go to the Macros menu, select “Customize,” and navigate to the “My Macros” page. Make sure the macro you just saved appears in the “My Macros” list. If it doesn’t, click the “Add” button to include it. Once added, select the macro, click on “Runs at Events,” and then click the “Events” button. In the “Select Events” dialog, ensure that “File Opened” is enabled.
// 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 ); } if( document.GetLine( 1 ) == ".LOG" ) { document.selection.EndOfDocument(); document.writeln( "" ); document.writeln( return_date_long_time() ); }
- AuthorPosts
- You must be logged in to reply to this topic.