Open Source Blogs
Immerse yourself in SAP open source! Discover collaborative projects, insights into the latest technologies, and best practices in open source development.
Showing results for 
Search instead for 
Did you mean: 
Moment.js has officially been deprecated as of September 2020. The Moment.js team has announced the end of the active development and they no longer update or add new features. The reasons for such a decision are explained on the Moment.js website.

But how does the deprecation of Moment.js affect Fundamental Library NGX?

One of the Fundamental Library NGX adapters, MomentDateTimeAdapter was using the Moment.js library. Considering that Moment.js objects are mutable. This was a common source of complaints about Moment and this bug was also reflected in the Fundamental Library NGX adapter. The latest version update on the 22nd of March, 2022 reflects this bug. In order to fix this bug, we incorporated Day.js library.

Advantages of using Day.js.

  • Day.js is actually built in the way it mimics MomentJS’s APIs

  • Day.js variables are immutable.

  • Day.js minified file is only 2Kb



We are going throught an example for a quick comparison between Moment.js and Day.js in Fundamental Library NGX.


Firstly you need to import the moment library. If you are already using Fundamental Library NGX you don't need to install the library. It will be automatically installed.

import moment, { Moment } from 'moment';

The code below, returns the formatted date string in the given format.

moment().format('dddd, MMMM Do YYYY, h:mm:ss A');
// output => "Friday, October 4th 2019, 7:12:49 PM"
moment().format('ddd, hA');
// output => "Fri, 7PM"



The Fundamental Library NGX is currently working to merget the latest changes and incorporate Day.js as an option for the developers to use.

Similarly to Moment.js, you will need to import the Day.js library.
import dayjs, { Dayjs } from 'dayjs';

Additionally, if you would like to used Advance format for the date and time, you will need to add the code snippet below.
import advancedFormat from 'dayjs/plugin/customParseFormat';

The code below, returns the formatted date string in the given format.
dayjs().format('dddd, MMMM D YYYY, h:mm:ss A');
// output => "Friday, October 4th 2019, 7:12:49 PM"
dayjs().format('ddd, hA');
// output => "Fri, 7PM"
// dayjs requires advancedFormat plugin to support more format tokens
dayjs().format('dddd, MMMM Do YYYY, h:mm:ss A');
// output => "Friday, October 4th 2019, 7:12:49 PM

Fundamental Library NGX is providing the developers with both options. Developers who use Moment.js in their existing applications can use MomentDateTimeAdapter since the migration to DayDateTimeAdapter can cause issues. Although, we do not recommend picking MomentDateTimeAdapter for the new projects. We also recommend developers to switch to DayDateTimeAdapter if they are not using Moment.js in their existing application.

Follow the Fundamental Library Styles Community to stay tuned for the updates. If you have any questions feel free to post them in the comment section below or in SAP Community Q&A.