Get current time
Posted: 10 Dec 2017, 01:36
I was wondering if there is any way to get the current system time as I want to log data to a text file including the current time
Thanks,
Theo
Thanks,
Theo
Code: Select all
//========
now= new Date();
aaaa = now.getFullYear();
mm = now.getMonth() + 1;
jj = now.getDate();
hh = now.getHours();
mn = now.getMinutes();
ss = now.getSeconds();
date_heure= aaaa + " " + mm + " " + jj + " " + hh + "-" + mn + "-" + ss ;
//=========
var fichier_date_time = new File();
fichier_date_time_chemin_complet= "C:\\temp\\date_time.csv"
fichier_date_time.open(fichier_date_time_chemin_complet,File.WriteOnly | File.Text );
w_art = date_heure + "\n";
fichier_date_time.writeText(w_art);
fichier_date_time.close();
im not sure if you attached something to your post, but I cant see anything.MDLE46 wrote: ↑10 Dec 2017, 20:03 Bonjour,
J'ai sauvegardé ce code bien utile dans ma bibliothèque perso.
Ce script écrit dans un fichier texte en écrasant le contenu.
Si ce n'est pas trop compliqué, serai t’il possible d'avoir le même sans écrasement du contenu (en ajoutant à la fin).
Cordialement.
MDLE46.
Code: Select all
var fichier_date_time = new File();
fichier_date_time_chemin_complet= "C:\\temp\\date_time.csv"
fichier_date_time.open(fichier_date_time_chemin_complet,File.WriteOnly | File.Text | File.Append );
Code: Select all
w_art = date_heure() + "\n";
fichier_date_time.writeText(w_art);
//========
function date_heure() {
now= new Date();
aaaa = now.getFullYear();
mm = now.getMonth() + 1;
jj = now.getDate();
hh = now.getHours();
mn = now.getMinutes();
ss = now.getSeconds();
zz = aaaa + " " + mm + " " + jj + " " + hh + "-" + mn + "-" + ss ;
return zz
}
Code: Select all
fichier_date_time.close();
thanks for the help, I was curious if there is a way to read the directory where to save it from an ini.francois wrote: ↑11 Dec 2017, 08:38 At the beginning of your script, a code action :Code: Select all
var fichier_date_time = new File(); fichier_date_time_chemin_complet= "C:\\temp\\date_time.csv" fichier_date_time.open(fichier_date_time_chemin_complet,File.WriteOnly | File.Text | File.Append );
Code: Select all
var file_ini = new IniFile();
file_ini.setSection("gene");
file_ini.setKeyValue("x",1782);
file_ini.setKeyValue("dir_temp","d:/temp");
file_ini.save("C:/test/azerty.ini");
Code: Select all
var file_ini = new IniFile();
file_ini.load("C:/test/azerty.ini");
file_ini.setSection("gene");
x= file_ini.keyValue("x");
dir_temp= file_ini.keyValue("dir_temp");
Console.print(x)
Console.print(dir_temp)