Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there a way of returning the date in one line?

As a beginner I am trying to understand if there is a way to convert this into a one-liner? Have tried to search of course before asking. I need an output in Selenium that outputs HHMM without : . So, I need to know if there’s a way to put this into oneline?

const now = new Date();
console.log(now.getHours() + "" + now.getMinutes());

Thanks a lot for helping out!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This could be an option

console.log(new Date().toTimeString().split(':').slice(0,2).join(' '))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading