Front End Technology Articles - Page 578 of 652
4K+ Views
To format a JavaScript date into “yyyy-mm-dd” format, use the toISOString() method. It converts using ISO standard i.e.YYYY-MM-DDTHH:mm:ss.sssExampleYou can try to run the following code to format a date. Live Demo JavaScript Dates var date, res; date = new Date(); res = date.toISOString(); document.write(res); Output2018-12-15T08:13:47.648Z
19K+ Views
In this tutorial, we will learn to convert the epoch Date to a meaningful JavaScript date. The epoch date is a representation of the date in milliseconds, and it is a total number of milliseconds since 1st January 1970 since the UNIX epochs started. Users can convert the total number of milliseconds into the meaningful date string using various approaches explained below. Using the new Date() Object In this approach, we will create the object of the Date class. The constructor of the Date() class takes the total number of milliseconds since the epoch started and converts it into the ... Read More
7K+ Views
To convert a string to character array in JavaScript, is useful when you want to iterate over each charater of the string. It can be used for character manipulation like changing specific character of string. We will be understanding five different approaches for converting a string to character array. In this article we are having a string value and our task is to convert a string to character array in JavaScript. Approaches to Convert String to Character Array Here is a list of approaches to convert a string to character array in JavaScript which we will be discussing in this ... Read More
5K+ Views
In this tutorial, we will learn to get the date and time since epoch in JavaScript. Sometimes, programmers need to find the total number of milliseconds, seconds, days, or other things from 1 January 1970 since the UNIX epochs started. So, users can use the Date() class of JavaScript or the Moment.js library of JavaScript to get the date and time since the epoch started. Using the Object of Date() Class In this approach, we will learn to get the current date from the UNIX epoch that has been started on 1 January 1970. In JavaScript, the Date() class contains ... Read More
26K+ Views
In this tutorial, we will learn to count JavaScript array objects. The array is the data structure containing the strings, numbers, objects, etc., in JavaScript. The object is the one kind of entity that contains properties and methods related to it. We can access the object's properties and invoke the object method using the object's references. Generally, To find the array length, we can use the array.length() method and it returns the total number of elements that the array includes. But what if we need to count only object elements? Here, this tutorial has various approaches to counting the total ... Read More
3K+ Views
In this tutorial, we will learn to clone a Date object in JavaScript. We can create a new object of the Date class that contains the date and time according to the user’s requirement. Sometimes, it needs to copy the date, which means cloning it. In such cases, users can use the different approaches given below. Also, we will learn to set the new time and date in the cloned date in this tutorial. Clone a Date using the Date.getTime() Method Users can simply create the new object of the Date class and get the total number of milliseconds from ... Read More
29K+ Views
In this tutorial, we will learn how to add 2 Hours to a JavaScript Date object. Here we will discuss two methods which are following. Using the getTime() Method Using the setHours() Method Using the getTime( ) Method JavaScript date getTime() method returns the numeric value corresponding to the time for the specified date according to universal time. The value returned by the getTime() method is the number of milliseconds since 1 January 1970 at 00:00:00. Syntax Following the syntax for the getTime() method − Date.getTime() Approach To add 2 hours to the Date Object first, we ... Read More
12K+ Views
In this tutorial, we will learn how to add 30 minutes to a JavaScript Date object. Here we will discuss two methods which are following. Using the setMinutes( ) Method Using the getTime() Method Using the setMinutes Method The setMinutes() function of the date object accepts an integer representing the Minutes and replaces the value of the Minutes in the current date with it. Syntax Date.setMinutes(min, sec, ms); Parameter min − An integer between 0 and 59, representing the minutes. sec − An integer between 0 and 59, representing the seconds. If you specify the sec ... Read More
2K+ Views
We humans can understand how the date and time are divided and printed. On theother hand, JavaScript interprets the date based on a timestamp generated from Unix time, which is a value made up of milliseconds. JavaScript Platform-independent date objects represent a single point in time. A millisecond counter has been included in Date objects since January 1, 1970 UTC. YYYY-MM-DD is the most used JavaScript date format. Timed Dates YYYY-MM-D DTHH:MM:SSZ. A date data type is not available in JavaScript. Dates can be set, obtained, and changed using various methods provided on the Date object in JavaScript. In ... Read More
4K+ Views
To add new value to an existing array in Javascript, it can be achieved using various ways. We will be understanding seven different approaches for adding a new element to existing array. In this article we are having an array of numbers and our task is to add new value to an existing array in JavaScript. Approaches to Add New Value to Existing Array Here is a list of approaches to add new value to an existing array in JavaScript which we will be discussing in this article with stepwise explaination and complete example codes. ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP