How do I get the current month as an integer, and as a string?
So for this month, I would want "7" and the string "July".
Is there an easy way to do this without a lot of string parsing and a lookup list for month names?
How do I get the current month as an integer, and as a string?
So for this month, I would want "7" and the string "July".
Is there an easy way to do this without a lot of string parsing and a lookup list for month names?
What you need is the clock
command.
http://www.tcl.tk/man/tcl8.5/TclCmd/clock.htm#M7
To get the textual representation of the month, use:
clock format [clock seconds] -format %B
And the numeric representation:
clock format [clock seconds] -format %N
My company's Tcl is at version 8.4 and the %N format does not work. I guess it is a Tcl 8.5 feature. To get around that issue:
set monthNumber [string trimleft [clock format [clock seconds] -format %m] 0]
In tcl 8.4 you can use %h and it will return the abbreviated month name ( eg. Oct )