Coder Social home page Coder Social logo

deno_dayjs's Introduction

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.

Example

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/<pluginName>.

Week of year

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

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

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

deno_dayjs's People

Contributors

jiawei397 avatar j053fabi0 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.