Working With Time- Node-Red Programming
Working With Time is very common in all programming languages. In this tutorial I want to take you through the basics of dealing with dates and times in JavaScript and some code snippets that I commonly use in my flows. The key to working with time in JavaScript is the Date object. So the first thing you need to do is to get a date object. There are several ways of doing this but the most basic is: var d=new Date(); This creates a date object with the current date and time if you print it it looks like this. 2020-06-08T16:14:36.457Z However this is not the only way you can create a new Date object there are several other methods which you might find useful: new Date() new Date(year, month, day, hours, minutes, seconds, milliseconds) new Date(milliseconds) new Date(date string) Example:. Creating a Object Using a Date String var date = new Date(‘September 22, 2018 13:22:13’) JavaScript Time Stamp and Unix Time stamp JavaScript stores time in milliseconds since Jan 1st 1970 (UTC) (Unix Time). However if you have data with a Unix time stamp then this will be seconds and not milliseconds. So to convert a Unix time stamp … Continue reading Working With Time- Node-Red Programming
Copy and paste this URL into your WordPress site to embed
Copy and paste this code into your site to embed