Navigation

    MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    UNSOLVED Getting date inside the config.js

    Troubleshooting
    3
    3
    521
    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
      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
      • cowboysdude
        cowboysdude Project Sponsor 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
          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

          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 Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
          This forum is using NodeBB as its core | Contributors
          Contact | Privacy Policy