0

My goal is open a text.txt with 3 different dates and times in UTC

  1. 2020-07-31T21:43:00.000Z
  2. 2020-07-30T21:43:00.000Z
  3. 2020-07-28T21:43:00.000Z

modify those dates in EST time and write on a text2.txt file

I know how to open text.txt and write the same 3 dates on text2.txt, but I have no idea how to convert the dates under text.txt

// Require the given module 
var fs = require('fs'); 

// Use readFile() method 
fs.readFile('text.txt', 'utf-8', function(err, data) { 

// Write the data read from text.txt 
// to a file text2.txt 
if( !err ) 
fs.writeFile('text2.txt', data, (err)=>{ 
    if( err ) { 
        throw err; 
    } 
}); 
else
throw err; 

}); 
  • Hi. It looks like you're reading the entire file as text into a single `data` variable, and then just writing that data to another file. You should start by considering *doing something* with that data. It would be better to read one line at a time (hint: `readline`) , but then how will you turn those lines of text into dates? And then once you have a date how will you convert it to another time zone? Then how will you turn it back into a line of text in the format you want in your output file? Then how will you write line by line to the output file? – Matt Johnson-Pint Aug 04 '20 at 16:51
  • If you think through those steps, you'll see that you have multiple things to consider and you have barely scratched the surface with your program. Thus, your question is really not asking one question, but for a complete end-to-end-program. That's not really what StackOverflow is about. You'll also find, if you search well, that each of these steps has their own questions and answers on StackOverflow already. It's your job to seek them out and put them together. If you get *stuck*, then show your work and someone can help you find the problem, but you have to start with more than what's here. – Matt Johnson-Pint Aug 04 '20 at 16:54
  • Thanks I'll try! – Roberto Pagoria Aug 05 '20 at 02:15

0 Answers0