19 May 2009

Time/Date Formats

In yesterday's entry, System Time/Date Script, I showed how to use the built-in Time function to display the current (system) time and date.

To change format, the strftime method has a number of options available.

Its basic format is

strftime(format)

where format is the format string to be used, which may be specified with the following:
  • %A - Full day of the week (Sunday, Monday, etc.)
  • %a - Abbreviated day of the week (Sun, Mon, etc.)
  • %B - Full month (January, February, etc.)
  • %b - Abbreviated month (Jan, Feb, etc.)
  • %c - Current Date and Time (system clock format)
  • %d - Day of the month (01-31)
  • %H - Time of day in 24-hour format (00-23)
  • %I - Time of day in 12-hour format (01-12)
  • %j - Day of the year (001-366)
  • %M - Minutes (00-59)
  • %m Numerical month of the year (01-12)
  • %p - Displays AM or PM after the time
  • %S - The number of seconds (00-60, 60 being a "leap second")
  • %U - Week of the year, the first week starting with the first Sunday (00-53)
  • %W - Week of the year, the first week starting with the first Monday (00-53)
  • %w - Day of the week (0-6, 0 denoting Sunday)
  • %X - Displays the Time
  • %x - Displays the Date
  • %Y - Displays the Year as a 4-digit number (2009)
  • %y - Displays the Year as a 2-digit number (00-99)
  • %Z - Displays the default (system) Time Zone
  • %% - Displays a % character
Note that this is case sensitive.

So, as an example, to display the full date, including day, month and year, strftime would be set to:

strftime = ("%A, %d %B, %Y")


The result would be

Tuesday, 20 May, 2009

And that's it!

4 Comments So Far:

Miaucho said...

Hello! My name is Irene.
This script is wonderful!
Please, could you help me modifying some aspects of it? I'd like to hange the name of the months to my own names (example, february could be called "Beautiful month" :P) and the year, so they wouldn't the the real month and year? I'm sure it would be very easy for you to do it. But if you dont want to, its ok, no worries. Thank you very much!

Companion Wulf said...

Hi Irene,
Cool idea! I'll be looking into this certainly, but please bear with me, as I don't have as much time as I'd like any more. I'm sure you know how it is! ~Wulf

Miaucho said...

Oh, thank you so much! It would be great! I'll be waiting for sure!

Companion Wulf said...

Yes, there is. Check out the System Time/Date Script. That will allow you to create a window that can be placed on the Status Menu page. And as far as actually pressing a key, you can add an Input trigger so that when the particular key is pressed, the window will pop up saying "Current time is [Time]".

Post a Comment

Related Posts with Thumbnails
Template Design "Perfect World" by SkinCorner