title: How do i write a file in node js with name containing some date and time string in it?
body: <p>I am trying to write a file with fs  like:</p>
  <pre><code>const fs = require('fs');
  const path = require('path');
  let d = new Date();
  let filename = &quot;Source-&quot; + d.getDate() + &quot;\/&quot; + (d.getMonth() + 1) + &quot;\/&quot; + d.getFullYear() + &quot;-&quot;;
  filename += (d.getHours() + &quot;\:&quot; + d.getMinutes());
  filename += &quot;.txt&quot;;
  console.log(filename);
  let p = path.join('./',filename);
  fs.writeFile(p,&quot;Something&quot;,(err)=&gt;{
      console.log(err?err:'Success!');
  });
  </code></pre>
  <p><strong>This Logs</strong></p>
  <blockquote>
  <p>Source-4/1/2018-12:15.txt</p>
  <p>{ Error: ENOENT: no such file or directory, open 'E:\ttttt\Source-4\1\2018-12:15.txt'
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'E:\ttttt\Source-4\1\2018-12:15.txt' }</p>
  </blockquote>
  <p>File is not written and the above error comes.</p>
  <p>How can I resolve this so that I am able to write file with a date and time in its fileName.</p>