How to transport Date and Time? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to transport Date and Time?

What is the best way to get the current Time, save it to firebase, and then, after downloading it at another device, showing it as a human-readable format? (in JS) Thanks in advance!

14th Jul 2017, 9:48 AM
Ltzu
Ltzu - avatar
2 Answers
+ 9
you can do something similar to this code which return a formatted string of the date you can make the formatter function better by having it accept a format string ('dd/MM/YYYY' for example) which determines the output format take into consideration tho that Firebase supplies its own timestamp which determined by the server and not on the client https://firebase.google.com/docs/reference/js/firebase.database.ServerValue https://code.sololearn.com/WZUdi030ES84/?ref=app
14th Jul 2017, 10:13 AM
Burey
Burey - avatar
+ 4
I don't know about the firebase part but my code shows the time in a human readable format https://code.sololearn.com/Woz98VH77WF1/?ref=app
14th Jul 2017, 9:51 AM
Cheesy Game Studios
Cheesy Game Studios - avatar