Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

accessing system time

I'm adding a feature to my project that displays "This Save File was last loaded on (date) at (time)" but I can't figure out a way to access system time.

Can anybody give me a hand?
 

poccil

Sponsor

To display the time string (where _timevalue_ is a time value returned from File#mtime):

Code:
time=Time.at(timevalue)
string=sprintf("This save file was last loaded on %s at %s",
  time.strftime("%B %d, %Y"),time.strftime("%I:%M %p"))

This example uses methods from the Time class.  Some examples:

  • Time.now returns the current time.
  • Time.at(X) returns a Time object given the file time X (returned from File#mtime).
  • Time.strftime(formatstring) formats a Time object.  See the RPG Maker XP help file for details.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top