![]() |
Given a Date Object and the task is to remove the time portion from the object using JavaScript. JavaScript split() Method: This method is used to split a string into an array of substrings, and returns the new array. Syntax: string.split( separator, limit ) Parameters:
Return value: It returns a new array, having split items. Example 1: This example splits the date by using (‘ ‘) and then takes the value at index = 0 of the array returned after split using split() method. Javascript
Output
12/05/2019 Example 2: This example is quite similar to the previous one. This example first splits the date by using (‘ ‘) and then take the value at index = 0 of the array returned after split using split() method. It works with Date objects. Javascript
Output
2023-06-14 |
Reffered: https://www.geeksforgeeks.org
JavaScript |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 8 |