REALTIME to Variable (Time class)

deilin

Ranger/Elementalist
Veteran
Joined
Mar 13, 2012
Messages
1,188
Reaction score
172
First Language
English
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?
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
Based on the help file:


Time.strftime(format)


where format can be:

%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...
 
Last edited by a moderator:

deilin

Ranger/Elementalist
Veteran
Joined
Mar 13, 2012
Messages
1,188
Reaction score
172
First Language
English
It errors out:

No Method for strftime

or tSTRING error

or %string error
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
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)
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,078
Members
137,580
Latest member
Snavi
Top