I don't know JavaScript, but I am familiar with following directions. I know a little PHP.
I'm looking for a piece of JS that will output a particular string of text for my header, based on the user's current time.
For example:
12:00AM - 12:00PM - Good Morning! 12:00PM - 6:00PM - Good Afternoon! 6:00PM - 12:00AM - Good Evening!
JavaScript does not have any print object or print methods. You cannot access output devices from JavaScript. The only exception is that you can call the window.print() method in the browser to print the content of the current window.
Try following piece of Javascript code:
var today = new Date() var curHr = today.getHours() if (curHr < 12) { console.log('good morning') } else if (curHr < 18) { console.log('good afternoon') } else { console.log('good evening') }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With