Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript date to string format

var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
var today  = new Date();

console.log(today.toLocaleDateString("en-US")); // 9/17/2016
console.log(today.toLocaleDateString("en-US", options)); // Saturday, September 17, 2016
console.log(today.toLocaleDateString("hi-IN", options)); // शनिवार, 17 सितंबर 2016
Comment

convert date to string format dd/mm/yyyy javascript

// Convert Date.now() to Formatted Date in "dd-MM-YYYY".
function convertDate(inputFormat) {
  function pad(s) { return (s < 10) ? '0' + s : s; }
  var d = new Date(inputFormat)
  return [pad(d.getDate()), pad(d.getMonth()+1), d.getFullYear()].join('-')
}

console.log(convertDate('Mon Nov 19 13:29:40 2012')) // => "19-11-2012"
Comment

date to string format javascript

var today = new Date();
today.toISOString().substring(0, 10);
Comment

date to string format javascript

function formatDate(date) {
    var d = new Date(date),
        month = '' + (d.getMonth() + 1),
        day = '' + d.getDate(),
        year = d.getFullYear();

    if (month.length < 2) 
        month = '0' + month;
    if (day.length < 2) 
        day = '0' + day;

    return [year, month, day].join('-');
}
 
console.log(formatDate('Sun May 11,2014'));
Comment

PREVIOUS NEXT
Code Example
Javascript :: parse local json file 
Javascript :: reactjs limit text display 20 200 characters 
Javascript :: express redirect to url 
Javascript :: how to import jquery in js file 
Javascript :: how to wait until a variable is set javascript 
Javascript :: convert a string to a number in js 
Javascript :: click outside box jquery 
Javascript :: javascript dedupe array 
Javascript :: angular access current scope from console 
Javascript :: generate component with module angular 8 
Javascript :: trigger window resize 
Javascript :: Installation failed, reverting ./composer.json and ./composer.lock to their original content. 
Javascript :: react image compression 
Javascript :: get number from range line js 
Javascript :: vue.js function to always uppercase when the client input lowercase 
Javascript :: list methods of object js 
Javascript :: nuxt head script content 
Javascript :: get element by 
Javascript :: javascript convert minutes to hh mm 
Javascript :: splidejs autoscroll pauseOnHover 
Javascript :: javascript reduce array of objects 
Javascript :: generate random hex 
Javascript :: javascript settimeout loop 
Javascript :: Redirect replacement in react 
Javascript :: alert.alert react native style 
Javascript :: chart js x axis start at 0 
Javascript :: string repeat codewars javascript 
Javascript :: refresh datatable on button click with maintaining paging 
Javascript :: run cypress 
Javascript :: could not resolve module fs react native 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =