Automatic date & time

Bonjour tout-le-monde.
Y a-t-il moyen d’inscrire la date automatiquement (Timestamp) à chaque modification en haut d’une note ou même dans le titre (comme en HTML avec un script)?

Hello everyone.
Is there a way to write the date automatically (Timestamp) after each modification at the top of a note or even in the title (as in HTML with a script)?

1 Like

Hello,

no, I don’t think there is.

You could write a script that monitors the file system for changes and adds/updates the timestamp inside .md files whenever a change is detected. You could probably also use the api for that.

Hello!

Thanks for your help. I use now this well known script and it works! (in android app, not in desktop version)

<span style="color: white;">updated: <span id="datetime"></span></span>
<br />
<div>
<script>
var dt = new Date();
document.getElementById("datetime").innerHTML = (("0"+dt.getDate()).slice(-2)) +"."+ (("0"+(dt.getMonth()+1)).slice(-2)) +"."+ (dt.getFullYear()) +" at "+ (("0"+dt.getHours()).slice(-2)) +":"+ (("0"+dt.getMinutes()).slice(-2)) + " AST";
</script>

</div>

Le jeu. 14 nov. 2019 à 15:31, Shamp0o via Joplin Forum cozic@discoursemail.com a écrit :

It does not work so well. I just realized that it shows the date of the last opening of a note. That’s not what I want.

Yes, I guess rather than setting dt to the current time, you would need to read the updated_time or user_updated_time attribute of the note, if they exist in the model.

You say the code you posted runs on Android but not on desktop. Does it mean we can run javascript in notes on Android? I wonder why there is a difference between Android and desktop.

IMO, this should not work. Running scripts in Joplin should be blocked or at least only allowed after changing a setting. @laurent, why is it possible to run scripts on mobile?

I’d need to check. Both can run scripts since we need this for checkboxes and other dynamic elements. The sandbox for Electron is tighter since I use stronger security settings after someone found a security issue, but I forgot what was done for mobile.

Anyway, the 2 or 3 scripts I tried do not work as I hoped including in my blog (HTML). They only display the date and time of opening of the file which is little interest (and I dont understand why). But I’m still happy to have unintentionally highlighted a possible security issue.

De toutes façons, les 2 ou 3 scripts essayés ne fonctionnent pas comme je l’espérais y compris sur mon blog HTML. Ils affichent seulement la date et heure d’ouverture du fichier ce qui n’a guère d’intérêt (et je ne comprends pas pourquoi). Mais je suis tout de même content d’avoir involontairement mis en évidence une possible faille de sécurité.

Patrice (Nettlebay)

Le sam. 16 nov. 2019 à 09:17, Laurent via Joplin Forum cozic@discoursemail.com a écrit :