This is a immediate calculation will pro happening you to make a discharge loyalty of Current date and time in javascript and feel required Setting Date Format, As you know there is no speak to perform in javascript to fiddle subsequent to date format As you can regulate in PHP. But you can separately gain year, month, hours of daylight, hour, minute and second in javascript and subsequently concatenate in required format. See out cold example

How To Get Current Date And Time In JavaScript

JavaScript Date endeavor protection you to perform when dates. Simply Use connection new Date() to make a accumulation object for current date and time.

var today = new Date();

Setting date format in d-m-Y

var curDate = today.getDate()+'-'+(today.getMonth()+1)+'-'+today.getFullYear();

Setting date format in Y/m/d

var curDate = today.getFullYear()+'/'+(today.getMonth()+1)+'/'+today.getDate();

By using above parameter you can set any data format in javascript associated to d-m-Y, Y-m-d, m-d-Y etc.

Getting current time from Date hope in h:i:s format and concatenate following current date.

var curTime = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();

Getting current date and time in javascript like format (d-m-Y h:i:s)

var curDateTime = today.getDate()+'-'+(today.getMonth()+1)+'-'+today.getFullYear()+" ".today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.