It returns a number, from 1 to 31, representing the day of the month.
Return value: It returns a number, representing the year of the defined date
Return value: It returns a number, from 0 to 11, representing the month.
- start: This parameter is required. It specifies the position from where to start the extraction. First character is at position 0
- end: This parameter is optional. It specifies the position (excluding it) where to stop the extraction. If not used, slice() selects all characters from the start-position till the end of string.
It returns a string, representing the extracted part of the string.
- replace() method: This method searches a string for a defined value, or a regular expression, and returns a new string with the replaced defined value.
- searchVal: This parameter is required. It specifies the value, or regular expression, that is going to replace by the new value.
- newvalue: This parameter is required. It specifies the value to replace the search value with.
Returns a new string where the defines value(s) has been replaced by the new value.
Example 1: This example format the date in dd/mm/yyyy by checking both date and month, If they are not in 2 digits the zero is added to make them 2 digits.
Example 2: This example first slice the date part from the date object and then format the date in dd/mm/yyyy.
Please Login to comment...