REALTIME to Variable (Time class)

Looking in the script help > Standard Library > Built-in Classes > Object

I came across the Time class, which from what I can read, looks at the time/date settings of the host OS.

I can get Time.now to display a long unneeded display of the date and time, how do I get it to just display certain data, and even store it into variables?
Based on the help file:


Time.strftime(format)


where format can be:

Spoiler
%A


Day of the week (Sunday, Monday ... )


%a


Day of the week in abbreviated form (Sun, Mon ... )


%B


Month (January, February ... )


%b


Month in abbreviated form (Jan, Feb ... )


%c


Date and time


%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


Month of the year (01-12)


%p


AM or PM


%S


Seconds (00-60, 60 being a leap second)


%U


Week of the year, with the first week starting on the first Sunday (00-53)


%W


Week of the year, with the first week starting on the first Monday (00-53)


%w


Day of the week (0-6 where 0 denotes Sunday)


%X


Time


%x


Date


%Y


Year in 4-digit format


%y


Year in 2-digit format (00-99)


%Z


Time zone


%%


The character %
if you wanna save into a variable:


variable_name = Time.strftime(format)


like:


$game_variables[1] = Time.strftime(%c)


or probably


$game_variables[1] = Time.strftime("%c")


Just read the whole Help entry for Time class...
It errors out:

No Method for strftime

or tSTRING error

or %string error
It errors out:


No Method for strftime


or tSTRING error


or %string error
try Time.now.strftime(format)


I think that should work (using Time directly doesn't have an object, so we fetch the current time object using the class method Time.now)
that was it.

it unlocked all of the class calls. thanks

Original thread: https://forums.rpgmakerweb.com/threads/realtime-to-variable-time-class.25214/