MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    Getting date inside the config.js

    Scheduled Pinned Locked Moved Unsolved Troubleshooting
    3 Posts 3 Posters 961 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C Offline
      cookblook
      last edited by

      Hello,

      is there an option/way to get the current date (day, month) inside the config.js. I need this to config a module.

      thanks

      1 Reply Last reply Reply Quote 0
      • cowboysdudeC Offline
        cowboysdude Module Developer
        last edited by cowboysdude

        You could look at an npm module ‘fs’… that reads and writes to files. :) This one should work

        https://www.npmjs.com/package/fs

        Here’s some examples: https://code-maven.com/reading-a-file-with-nodejs

        Here’s a snippet from one of my modules:

        fileWrite: function() {
                fs.writeFile(this.path, JSON.stringify(this.recipe), function(err) {
                    if (err) {
                        return console.log(err);
                    }
                    console.log("The Recipe file was saved!");
                });
            },
        
        S 1 Reply Last reply Reply Quote 0
        • S Do not disturb
          sdetweil @cowboysdude
          last edited by

          @cowboysdude no. He wants to get the date/time value dynamically on his module config strings. You can certainly get it in the code, either module or helper

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Enjoying MagicMirror? Please consider a donation!
          MagicMirror created by Michael Teeuw.
          Forum managed by Sam, technical setup by Karsten.
          This forum is using NodeBB as its core | Contributors
          Contact | Privacy Policy