javascript date to string format dd mmm yyyy

Date.prototype.toShortFormat = function() {

    let monthNames =["Jan","Feb","Mar","Apr",
                      "May","Jun","Jul","Aug",
                      "Sep", "Oct","Nov","Dec"];
    
    let day = this.getDate();
    
    let monthIndex = this.getMonth();
    let monthName = monthNames[monthIndex];
    
    let year = this.getFullYear();
    
    return `${day}-${monthName}-${year}`;  
}

// Now any Date object can be declared 
let anyDate = new Date(1528578000000);

// and it can represent itself in the custom format defined above.
console.log(anyDate.toShortFormat()); 

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
convert date format to dd/mm/yyyy in javascript js date to string mm/dd/yyyy javascript convert date to string format mm/dd/yyyy javascript convert date format dd/mm/yyyy to string javascript yyyy mm dd to string javascript date format mm dd yyyy javascript date to string format yyyymmddhhmmss javascript date to string dd/mm/yyyy convert date to string java script dd/mm/yyyy date to string javascript yyyy-mm-dd date to string dd/mm/yyyy javascript javascript date to string format dd mm yyyy hh mm javascript convert date to string format dd mm yyyy hh mm convert date to string javascript dd/mm/yyyy js format date dd/mm/yyyy js date to string dd.mm.yyyy javascript date to string format dd mm yyyy hh mm ss js convert date to string dd/mm/yyyy javascript date format date to string yyyymmdd javascript date format date to string yymmdd javascript format date to string dd/mm/yyyy jquery convert date to string format dd/mm/yyyy javascript convert date to string format dd/mm/yyyy date to string just mm/dd/yyyy javascript js date to string format yyyy-mm-dd convert date to string in javascript dd-mm-yyyy javascript date to format dd/mm/yyyy javascript date to string format yyyy-mm-dd javascript convert string date yyyyMMdd to String Date dd-MMM-yyyy date to string format dd/mm/yyyy javascript javascript date to string mm/dd/yyyy javascript convert datetime to string format dd/mm/yyyy javascript date to string format dd/mm/yyyy js script string dd-MMM-yyyy to date 20210127 js script string dd-MMM-yyyy how change to string 20210127 date to string javascript dd/mm/yyyy
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source