32 lines
521 B
Markdown
32 lines
521 B
Markdown
# Moment.js
|
||
|
||
This guide shows you how to install and use Moment.js, a popular date library in ToonBoom Harmony.
|
||
|
||
Install it from NPM and create a new script file:
|
||
|
||
```sh
|
||
❯ npm install moment
|
||
❯ touch ./src/scripts/moment.ts
|
||
```
|
||
|
||
Use ES modules to import the library:
|
||
|
||
```ts
|
||
// src/scripts/moment.ts
|
||
import moment from "moment";
|
||
|
||
MessageLog.trace(moment().locale("es").format("LLLL"));
|
||
```
|
||
|
||
Build it:
|
||
|
||
```sh
|
||
❯ npm run build
|
||
```
|
||
|
||
Then run `dist/moment.js` in Harmony:
|
||
|
||
```txt
|
||
martes, 18 de noviembre de 2025 12:23
|
||
```
|