Enter Current time with Button inside Template

That’s definitely possible with regex

var currentDate = new Date();
var current_time = currentDate.getHours() + ":" + currentDate.getMinutes() + ":" + currentDate.getSeconds();
const filepath = "Path/To/Your/Time_Log_Note.md"
const file = tp.file.find_tfile(filepath) 
var content = tp.file.content
var time_regex = /Time Here\n-/g
var new_content = content.toString().replace(time_regex, current_time)
await app.vault.modify(file,new_content)

You can add this code to a templater note enclosed with “<%* code here %>”

Or you can choose to use a templater js script file that would look like this (I prefer this way since it looks cleaner and opens in vscode since it’s a .js file):

change_time.js file in templater folder

async function my_function (tp,app) {

    var currentDate = new Date();
    var current_time = currentDate.getHours() + ":" + currentDate.getMinutes() + ":" + currentDate.getSeconds();
    const filepath = "Path/To/Your/Note.md"
    const file = tp.file.find_tfile(filepath) 
    var content = tp.file.content
    var time_regex = /Time Here\n-/g
    var new_content = content.toString().replace(time_regex, current_time)
    await app.vault.modify(file,new_content)

}

module.exports = my_function

Templater note that calls this function (change_time_template.md):

<% tp.change_time(tp,app) %>

Button:

```button
name Create New Insta Tweet
type append template
action Path/To/Templater/Note/change_time_template
color yellow