
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10483 Articles for Web Development

3K+ Views
To get the current year, use the getFullYear() JavaScript method. JavaScript date getFullYear() method returns the year of the specified date according to local time. The value returned by getFullYear() is an absolute number. For dates between the years 1000 and 9999, getFullYear() returns a four-digit number, for example, 2008.ExampleYou can try to run the following code to get the current year −Live Demo JavaScript getFullYear Method var dt = new Date("December 30, 2017 21:25:10"); document.write("getFullYear() : " + dt.getFullYear() ); OutputgetFullYear() : 2017

31K+ Views
In this tutorial, we will learn to check whether a JavaScript date is valid or not. Let’s understand why we need to validate the date in JavaScript by example. Suppose you have developed an application that takes some information in the submission form from the user. Users can make a mistake. What if they enter the wrong date in the input box? In such a case, developers need to validate the date. Here, we have three different methods to validate the date. Using the getTime() Method Using the isFinite() Method Using the Moment JS isValid() Method Using the ... Read More

488 Views
To initialize a JavaScript Date to midnight, set hours like the following −setHours(0,0,0,0);ExampleYou can try to run the following code to set a date to midnight −Live Demo var dt; dt = new Date(); dt.setHours(0,0,0,0); document.write(dt); OutputMon May 28 2018 00:00:00 GMT+0530 (India Standard Time)

7K+ Views
While developing the applications, sometimes it needs to compare the only date. For example, you are developing some apps in which users must adhere to the deadline and pay for the subscription. If the user pays at any time on or before the end date of the subscription, the user will be able to use the subscription continues. Otherwise, you need to stop the subscription. In this tutorial, we will learn to compare only the date part without comparing the time in JavaScript. In the above cases, we need to compare the two dates without focusing on the time. Approach ... Read More

234 Views
To convert a Unix timestamp to time, you can try to run the following code in JavaScript −ExampleLive Demo JavaScript Dates var unix_time = 1514791901 ; var date = new Date(unix_time*1000); // get hours var hrs = date.getHours(); // get minutes var min = "0" + date.getMinutes(); // get seconds var sec = "0" + date.getSeconds(); document.write("Time- "+hrs + ":" + min.substr(-2) + ":" + sec.substr(-2)); OutputTime- 13:01:41

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

293 Views
To create a date object from date string, just add the string like this −var date = new Date(2018,1,1);ExampleYou can try to run the following code to create date object from date string. Here, the month is indexed as 0 for Jan, 1 for Feb, etc in JavaScript −Live Demo JavaScript Dates var date; date = new Date(2018,0,1); document.write("Current Date: "+date); OutputCurrent Date: Mon Jan 01 2018 00:00:00 GMT+0530 (India Standard Time)

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

4K+ Views
In this tutorial, we are going to learn about how to calculate days from epoch using JavaScript. Here, we are going to use the Math.abs() and the Math.floor() methods to calculate days. First, we are going to learn about what an epoch is. What is Epoch? It is also referred to as epoch time or Unix time or Posix time. In a determining context, an epoch is the data and time relative to which a computer's clock and timestamps are determined. An epoch time is the number of seconds that have elapsed since Jan 1st, 1970 at midnight ... Read More