Answers for "javascript date from string dd/mm/yyyy HH mm ss"

1

javascript format date to dd-mm-yyyy

function pad2(n) {
  return (n < 10 ? '0' : '') + n;
}

var date = new Date();
var month = pad2(date.getMonth()+1);//months (0-11)
var day = pad2(date.getDate());//day (1-31)
var year= date.getFullYear();

var formattedDate =  day+"-"+month+"-"+year;
alert(formattedDate); //28-02-2021
Posted by: Guest on March-02-2021
2

java script print date in YYYY-MM-DD HH:MM:SS format

let date_ob = new Date();

// adjust 0 before single digit date
let date = ("0" + date_ob.getDate()).slice(-2);

// current month
let month = ("0" + (date_ob.getMonth() + 1)).slice(-2);

// current year
let year = date_ob.getFullYear();

// current hours
let hours = date_ob.getHours();

// current minutes
let minutes = date_ob.getMinutes();

// current seconds
let seconds = date_ob.getSeconds();

// prints date & time in YYYY-MM-DD HH:MM:SS format
console.log(year + "-" + month + "-" + date + " " + hours + ":" + minutes + ":" + seconds);
Posted by: Guest on March-02-2020
1

javascript convert date from mm/dd/yyyy to yyyymmdd

var yourdate = date.split("/").reverse().join("-");
Posted by: Guest on May-25-2020
0

javascript get current date format dd mm yyyy hh mm ss

dformat = [d.getDate(), d.getMonth() + 1, d.getFullYear()].join('/') + ' ' + [d.getHours(),d.getMinutes(),d.getSeconds()].join(':');
Posted by: Guest on February-26-2021
0

javascript date from string dd/mm/yyyy HH mm ss

var d='dd/mm/yy hh:MM:ss';
    var d1=d.split(" ");
    var date=d1[0].split("/");
    var time=d1[1].split(":");
    var dd=date[0];
    var mm=date[1]-1;
    var yy=date[2];
    var hh=time[0];
    var min=time[1];
    var ss=time[2];
    var fromdt= new Date("20"+yy,mm-1,dd,hh,min,ss);
Posted by: Guest on June-02-2021

Code answers related to "javascript date from string dd/mm/yyyy HH mm ss"

Code answers related to "Javascript"

Browse Popular Code Answers by Language