Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Insert formatted date
#1
My very first excursion into this great program, so be kind. I've been trying to write a macro to insert the system date into a text editor. All the format options are nice and when I overcome the first step I'll try 'em out. Right now the system short form will do. Please point the way.

RS
#2
1. Declare str variable.
2. With that variable, call function time with formatting string.
3. Paste that variable.

Example1 - month/day/year
Code:
Copy      Help
str s
s.time("d")
out s

More date-time formatting examples

Example2 - date
Code:
Copy      Help
out s.time("%x")

Example3 - date and time
Code:
Copy      Help
out s.time("%c")

Example4 - short-weekday short-month day hour:min
Code:
Copy      Help
out s.time("%a %b %#d %H:%M")


As you see, %x is replaced to date, %#d to day, etc.
Characters that aren't preceded by % (in example - spaces and colon) are unchanged.
#3
Thank you, kind one! I thought it would be simple and it was, but somehow I missed the declaration. Also took a look at the dll GetLocalTime function and at least printed out the Hour. But that is the long way, I think.

RS


Forum Jump:


Users browsing this thread: 1 Guest(s)