Instantly share code, notes, and snippets.

@AdamDimech /TimeString.ijm Secret
Last active May 23, 2018

Embed
What would you like to do?
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