Util.Date
Skip to content
mnscript
string Util.Date(number, string) 

Description ​

Returns a formatted date.

Arguments ​

number - The time to format
string - The format pattern.

Returns ​

string - The formatted date.

Example ​

msc
using System;
using Console;
using Util;

number time = System.Time();

// Formats [day/month/year - hour/minute/second]
string formattedTime = Util.Date(time, "%d/%m/%Y - %H:%M:%S");

Console.WriteLine("The date is: "..formattedTime);

// Known formats that work on all platforms:

// Format   Description                 Example of the output
// %a       Abbreviated weekday name    Wed
// %A       Full weekday name           Wednesday
// %b       Abbreviated month name      Sep
// %B       Full month name             September
// %c       Date and time               09/16/98 23:48:10
// %d       Day of the month [01-31]    16
// %H       Hour, 24-hour clock [00-23] 23
// %I       Hour, 12-hour clock [01-12] 11
// %j       Day of the year [001-365]   259
// %m       Month [01-12]               09
// %M       Minute [00-59]              48
// %p       Either am or pm             pm
// %S       Second [00-60]              10
// %w       Weekday [0-6 = Sunday-Saturday]	3
// %W       Week of the year [00-53]    37
// %x       Date                        09/16/98
// %X       Time                        24:48:10
// %y       Two-digit year [00-99]      98
// %Y       Full year                   1998
// %z       Timezone                    -0300
// %%       A percent sign              %