For custom-delimited date formats, you have to pull out the date (or time) components from a DateTimeFormat
object (which is part of the ECMAScript Internationalization API), and then manually create a string with the delimiters you want.
To do this, you can use DateTimeFormat#formatToParts
. You could destructure the array, but that is not ideal, as the array output depends on the locale:
{ // example 1 let f = new Intl.DateTimeFormat('en'); let a = f.formatToParts(); console.log(a); } { // example 2 let f = new Intl.DateTimeFormat('hi'); let a = f.formatToParts(); console.log(a); }
Related Posts:
- How to format a JavaScript date
- How do I get the current date in JavaScript?
- Get String in YYYYMMDD format from JS date object?
- How to format a JavaScript date
- Compare two dates with JavaScript
- Compare dates with javascript
- Add days to JavaScript Date
- Parsing a string to a date in JavaScript
- Format JavaScript date as yyyy-mm-dd
- Add days to JavaScript Date
- How to validate date with format “mm/dd/yyyy” in JavaScript?
- How to subtract date/time in JavaScript?
- Getting current date and time in JavaScript
- Shortest way to print current year in a website
- Validate date in dd/mm/yyyy format using JQuery Validate
- How to subtract days from a plain Date?
- How to add 30 minutes to a JavaScript Date object?
- How do you convert a JavaScript date to UTC?
- Convert UTC Epoch to local date
- Convert normal date to unix timestamp
- Check time difference in Javascript
- How to convert date to timestamp?
- How to format a UTC date as a `YYYY-MM-DD hh:mm:ss` string using NodeJS?
- Moment Js UTC to Local Time
- Get hours difference between two dates in Moment Js
- Javascript: getFullyear() is not a function
- Google reCAPTCHA V3.0 not working. “ERROR for site owner: Invalid key type”
- Javascript split regex question
- Find object by id in an array of JavaScript objects
- How to set NODE_ENV to production/development in OS X
- How fix ‘Failed to load resource: the server responded with a status of 403’?
- How do I empty an array in JavaScript?
- JavaScript TypeError: Cannot read property ‘style’ of null
- Set style using pure JavaScript
- Check if element exists in jQuery
- Checking a Url in Jquery/Javascript
- Usage of the backtick character (`) in JavaScript
- Why is using “for…in” for array iteration a bad idea?
- Sorting strings in descending order in Javascript (Most efficiently)?
- Function is not defined – Uncaught ReferenceError
- Convert UTC date time to local date time
- How can I convert a string to boolean in JavaScript?
- “.addEventListener is not a function” why does this error occur?
- Download data URL file
- Why use Redux over Facebook Flux?
- Remove not alphanumeric characters from string
- Scroll to bottom of div?
- Open URL in new window with JavaScript
- Read XML file using javascript
- How to change the text of a label?
- How to check ‘undefined’ value in jQuery
- Detecting arrow key presses in JavaScript
- Data column(s) for axis #0 cannot be of type string in google chart dashboard [duplicate]
- JavaScript – Count Number of Visitor for Website
- Jquery Value match Regex
- Check if a JavaScript string is a URL
- Submit form without reloading page [duplicate]
- “React.Children.only expected to receive a single React element child” error when putting
and in a - What is the difference between Bower and npm?
- How to embed an autoplaying YouTube video in an iframe?
- Cannot read property ‘style’ of undefined — Uncaught Type Error
- clearInterval() not working [duplicate]
- How to make HTML element resizable using pure Javascript?
- how to use addHTML function in jsPDF
- Rock, Paper, Scissors, Lizard, Spock in JavaScript
- How to fix “TypeError: Right-hand side of ‘instanceof’ is not callable” when I use another module class?
- Change the selected value of a drop-down list with jQuery
- Uncaught SyntaxError: Unexpected token var
- window.location.href doesn’t redirect
- Custom “Uploads” Dir: “Edit Image” in Media Library broken
- Get loading state of wp data selector
- Customizer JS API: Adding Setting Dynamically Not Working
- Adding a text element in between title and blocks container
- How to check if customize previewer is refreshing?
- Remove type attribute from script added by wp_localize_script
- Google Map iframe in a tab issue
- Morris.js for WordPress?
- Where is the WP auto-save draft JavaScript?
- How to return div with custom attributes(Coding a Gutenberg Block)
- Popup box when Clicking on Insert into post button in wordpress
- JQuery not loading
- Uncaught TypeError: jQuery(…).slider is not a function
- WordPress update_user_meta onclick button with Ajax
- Inherit scripts from parent to childtheme
- WordPress wp_enqueue_script only adds text to top of page source
- Post title not saving
- wp_handle_upload returns a critical error response or invalid form submission
- Modal won’t appear on all pages
- I want to make a post api call once a post or page is published/updated and show a javascript alert box saying ‘Post has been published/updated’
- Add a Page Screen is Visually Blank
- Always render emoji with twemoji.js – not system emoji
- Enqueued script fails
- “jQuery Not Defined” Error When Connecting to PayPal
- Fade-in Fade-out doesn’t work in WordPress
- Setting wp_enqueue_script correctly
- [Vue warn]: Error in render: “TypeError: Cannot read property ‘wp:featuredmedia’ of undefined – REST API
- How can I put my own code in a wordpress page?
- Custom Media Meta fields to alter the generated image HTML that is inserted into a post for my animated GIF image player?
- wp_enqueue_scripts doesn’t work for template pages
- WOW.js Script Tag Initialization Header/Footer