Skip to content

Instantly share code, notes, and snippets.

@AdamDimech
Last active May 23, 2018 05:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdamDimech/66391d775d0d602a207b4dfc41e8556e to your computer and use it in GitHub Desktop.
Save AdamDimech/66391d775d0d602a207b4dfc41e8556e to your computer and use it in GitHub Desktop.
Prints a time string in ImageJ
macro "Time Stamp" {
MonthNames = newArray("01","02","03","04","05","06","07","08","09","10","11","12");
getDateAndTime(year, month, dayOfWeek, dayOfMonth, hour, minute, second, msec);
TimeString ="";
if (dayOfMonth<10) {TimeString = TimeString+"0";}
TimeString = ""+year+""+MonthNames[month]+""+dayOfMonth+""+TimeString;
if (hour<10) {TimeString = TimeString+"0";}
TimeString = TimeString+hour+"";
if (minute<10) {TimeString = TimeString+"0";}
TimeString = TimeString+minute+"";
if (second<10) {TimeString = TimeString+"0";}
TimeString = TimeString+second;
print("The generated time string is", TimeString); // Prints the time stamp
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment