• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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 911 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 Jan 11, 2019, 9:00 PM

    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
    • C Offline
      cowboysdude Module Developer
      last edited by cowboysdude Jan 12, 2019, 3:01 AM Jan 12, 2019, 2:57 AM

      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 Jan 12, 2019, 3:20 AM Reply Quote 0
      • S Offline
        sdetweil @cowboysdude
        last edited by Jan 12, 2019, 3:20 AM

        @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
        1 / 1
        • First post
          1/3
          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