JAVASCRIPT EXAMPLE · DATE & TIME

Current Date & Time

JavaScript Date object se current date aur time read karo.

Working code

const now = new Date();

console.log(now.toLocaleString());
Run Code ▶

Expected output

Output current device date/time ke according change hoga.

How it works

new Date() current date-time represent karne wala Date object banata hai.

toLocaleString() us value ko device/browser locale ke readable format me convert karta hai.

Try Yourself

const now = new Date();

console.log("Date:", now.toLocaleDateString());
console.log("Time:", now.toLocaleTimeString());

Learn this concept

Open JavaScript Tutorial →