Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. Object.assign(String.prototype, {
  2. formatDateYMD (splitChar) {
  3. let matchedString = this.match('[0-9]{4}([-/])[0-9]{2}[-/][0-9]{2}')
  4. const dutchMonths = ['jan', 'feb', 'mrt', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec']
  5. matchedString = matchedString[0].split(splitChar)
  6.  
  7. return `${matchedString[2]} ${dutchMonths[Number(matchedString[1] - 1)]}`
  8. }
  9. })
  10.  
  11. const myString = '1992-09-21'
  12. myString.formatDateYMD('-') // returns '21 sep'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement