I am generating a report and need put the current date/time in the filename, but all DOORS canned formats that I know of contain slashes and/or colons, which are not allowed in filenames, e.g.: stringOf(dateAndTime(today),loc,"yyyy-MM-dd")
mcnairk - Thu Apr 01 09:12:23 EDT 2010 |
Re: Current date/time in format yyyymmddhhmmss Here's some code to do what you want, irrespective of locale: void printZeroPrefixedInt(int i) { string s = i "" if (i < 10) s = "0" s print s } void printTime() { int now = intOf(dateAndTime(today)) Date d = dateOnly(today) int day = intOf(date(stringOf(d))) int diff = now-day int hours = diff / 3600 int mins = (diff - (3600 * hours)) / 60 int secs = diff - (hours * 3600) - (mins * 60) printZeroPrefixedInt hours printZeroPrefixedInt mins printZeroPrefixedInt secs } print stringOf(today, "yyyyMMdd") printTime |
Re: Current date/time in format yyyymmddhhmmss SystemAdmin - Thu Apr 01 10:28:49 EDT 2010 Ken. |