Recently, I was working on a TypeScript project where I needed to manipulate dates for a scheduling application. The task was simple: getting the current date in TypeScript. In this tutorial, I will explain how to get the current date in TypeScript using various methods.
Using the Native Date Object
The best way to get the current date in TypeScript is using JavaScript’s built-in Date object. I use this method frequently for simpler projects.
// Get current date and time
const currentDate: Date = new Date();
console.log(currentDate); // Outputs the full date and time
// Get only today's date (without time)
const today: Date = new Date();
today.setHours(0, 0, 0, 0);
console.log(today); // Outputs today's date with time set to midnight
// Format as MM/DD/YYYY (US format)
const formattedDate: string = `${currentDate.getMonth() + 1}/${currentDate.getDate()}/${currentDate.getFullYear()}`;
console.log(formattedDate); // Outputs something like 04/24/2025The Date object is available in all JavaScript environments, so you don’t need to install any additional packages. However, formatting options are limited, and you’ll need to write your own formatting logic.
You can see the exact output in the screenshot below:

One thing to note is that months in JavaScript are zero-indexed (January is 0, December is 11), which is why I add 1 when formatting the month.
Check out Add Months to a Date in TypeScript
Using the date-fns Library
When I’m working on larger projects that need more sophisticated date handling, I prefer using date-fns. It’s lightweight, modular, and follows functional programming principles.
First, install date-fns:
npm install date-fnsThen you can use it in your TypeScript code:
import { format, startOfDay } from 'date-fns';
// Get current date and time
const currentDate: Date = new Date();
console.log(currentDate);
// Get only today's date (start of day)
const today = startOfDay(new Date());
console.log(today);
// Format date in various ways
const formattedDate = format(currentDate, 'MM/dd/yyyy');
console.log(formattedDate); // Outputs like 11/22/2023
// More formatting examples
console.log(format(currentDate, 'MMMM d, yyyy')); // November 22, 2023
console.log(format(currentDate, 'EEEE, MMMM do, yyyy')); // Wednesday, November 22nd, 2023What I love about date-fns is that it’s tree-shakable, meaning you only import what you need, keeping your bundle size small.
Using moment.js
While moment.js is somewhat deprecated for new projects (in maintenance mode), many existing projects still use it. If you’re working with a codebase that already has moment.js, here’s how to use it:
npm install momentimport moment from 'moment';
// Get current date and time
const currentMoment = moment();
console.log(currentMoment.toDate());
// Get only today's date (start of day)
const today = moment().startOf('day');
console.log(today.toDate());
// Format date in various ways
console.log(currentMoment.format('MM/DD/YYYY')); // 11/22/2023
console.log(currentMoment.format('MMMM D, YYYY')); // November 22, 2023
console.log(currentMoment.format('dddd, MMMM Do YYYY')); // Wednesday, November 22nd 2023Moment.js has excellent formatting capabilities and timezone handling, but it’s larger than alternatives like date-fns.
Check out Create a Date from Year, Month, and Day in TypeScript
Using Intl.DateTimeFormat
For applications that need to support internationalization, the built-in Intl.DateTimeFormat is an excellent choice:
// Get current date
const currentDate: Date = new Date();
// Format date for US locale
const usFormatter = new Intl.DateTimeFormat('en-US', {
year: 'numeric',
month: '2-digit',
day: '2-digit'
});
console.log(usFormatter.format(currentDate)); // Outputs like 04/24/2025
// Format with more options
const detailedFormatter = new Intl.DateTimeFormat('en-US', {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric'
});
console.log(detailedFormatter.format(currentDate)); // Thursday, April 24, 2025
// Supporting different locales
const frenchFormatter = new Intl.DateTimeFormat('fr-FR', {
year: 'numeric',
month: 'long',
day: 'numeric'
});
console.log(frenchFormatter.format(currentDate)); // 24 avril 2025This method is great because it handles internationalization right out of the box. I often use this in applications that need to support users from different regions.
You can see the output in the screenshot below; this is so powerful.

Performance Considerations
When working on high-performance applications, date handling can sometimes impact performance. Here are my recommendations:
- Native Date object: Fastest for simple operations but lacks formatting options
- date-fns: Good balance of performance and features
- Intl.DateTimeFormat: Excellent for internationalization with acceptable performance
- moment.js: Consider alternatives for new projects due to size and performance concerns
In a recent project for a US client tracking real-time stock transactions, we needed to display timestamps in US Eastern Time. I used date-fns with time zone support:
import { format, utcToZonedTime } from 'date-fns-tz';
// Get current date in US Eastern Time
const estTimeZone = 'America/New_York';
const currentDateEST = utcToZonedTime(new Date(), estTimeZone);
// Format date for displaying transaction timestamps
const timestamp = format(currentDateEST, 'MMM d, yyyy h:mm:ss a zzz', { timeZone: estTimeZone });
console.log(timestamp); // Apr 24, 2025 10:45:23 AM ESTWorking with dates in TypeScript doesn’t have to be complicated. For most projects, I recommend using the native Date object for simple cases and date-fns for anything more complex. If internationalization is important, leverage Intl.DateTimeFormat.
I hope you found this guide helpful! If you have any questions or suggestions about working with dates in TypeScript, feel free to share them in the comments below.
Other TypeScript tutorials you may also like:

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.