https://github.com/jiawei397/deno_dayjs
Provides dayjs for Deno.
https://github.com/jiawei397/deno_dayjs
Last synced: about 1 month ago
JSON representation
Provides dayjs for Deno.
- Host: GitHub
- URL: https://github.com/jiawei397/deno_dayjs
- Owner: jiawei397
- Created: 2021-12-17T06:32:31.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-07-07T08:09:45.000Z (almost 2 years ago)
- Last Synced: 2025-03-24T19:05:08.901Z (about 2 months ago)
- Language: TypeScript
- Size: 25.4 KB
- Stars: 6
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# deno_dayjs
Provides `dayjs 1.11.5` for Deno.
Day.js is a minimalist JavaScript library that parses, validates, manipulates,
and displays dates and times for modern browsers with a largely
Moment.js-compatible API. If you use Moment.js, you already know how to use
Day.js.More info or API [here](https://deno.land/x/dayjs).
## Example
```ts
import dayjs from "https://deno.land/x/[email protected]/mod.ts";const day = dayjs().format("YYYY-MM-DD HH:mm:ss");
console.log(day);console.log(dayjs().startOf("date").toDate());
console.log(dayjs().startOf("date").format("YYYY-MM-DD HH:mm:ss"));
console.log(dayjs().endOf("date").format("YYYY-MM-DD HH:mm:ss"));
console.log(dayjs("20211027").endOf("date").format("YYYY-MM-DD HH:mm:ss"));
```# Plugins
> You can also get the URL from cdn yourself like:
> `https://esm.sh/[email protected]/plugin/`.## Week of year
```ts
import dayjs from "https://deno.land/x/[email protected]/mod.ts";
import weekOfYear from "https://deno.land/x/[email protected]/plugin/weekOfYear.ts";
dayjs.extend(weekOfYear);const date = dayjs(day);
console.log(date.year() + "-" + date.week());
```## Relative Time
```ts
import dayjs from "https://deno.land/x/[email protected]/mod.ts";
import relativeTime from "https://deno.land/x/[email protected]/plugin/relativeTime.ts";
dayjs.extend(relativeTime);dayjs().from(dayjs("1990-01-01")); // in 33 years
dayjs().from(dayjs("1990-01-01"), true); // 33 years
dayjs().fromNow();dayjs().to(dayjs("1990-01-01")); // "33 years ago"
dayjs().toNow();
```## UTC
```ts
import dayjs from "https://deno.land/x/[email protected]/mod.ts";
import utc from "https://deno.land/x/[email protected]/plugin/utc.ts";
dayjs.extend(utc);dayjs.utc().hour(); // 10
dayjs.hour(); // 18
```