npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@voidsolutions/vue-dateformat

v0.5.1

Published

A Vue.js component for formatting dates

Downloads

98

Readme

Vue DateFormat

This plugin is compatible with Vue 3

Vue-DateFormat is a component designed to format dates in a Vue.js application. It simple takes in a Date or String and converts it via toLocaleString() with different options passed in depending on your props.

For any bugs or feature requests, regarding this component, head on over to the issues page. For any queries that do not relate to this exact component, contact us at Void Solutions.

Installation

npm i @voidsolutions/vue-dateformat

Nuxt 3 Compatiblity

We need to create a plugin to use this component globally in Nuxt 3. Create dateformat.client.js to your /plugins directory. The contents of the file should be as follows:

import dateformat from "@voidsolutions/vue-dateformat";

export default defineNuxtPlugin(nuxtApp => {
    nuxtApp.vueApp.use(dateformat);
})

You can now use the component in your templates as follows:

<date-format :date="new Date()" />

Usage as a global component in Vue 3

In your main.js file, import the component and register it as a global component.

import { createApp } from 'vue'
const app = createApp(App)
...

import DateFormat from '@voidsolutions/vue-dateformat'
app.use(DateFormat);

...

app.mount('#app')

In your template, use the component as follows:


<date-format :date="new Date()" />

Props

| Prop | Type | Default | Description | | ----------- | -------------- | --------------------- | --------------------------------------------------- | | date | String or Date | new Date() | The date to be formatted | | no-seconds | Boolean | false | If true, the seconds will not be displayed | | no-minutes | Boolean | false | If true, the minutes will not be displayed | | no-hours | Boolean | false | If true, the hours will not be displayed | | no-days | Boolean | false | If true, the day of the month will not be displayed | | no-month | Boolean | false | If true, the month will not be displayed | | no-date | Boolean | false | If true, the date will not be displayed | | short-month | Boolean | false | If true, the month will be abbreviated | | no-year | Boolean | false | If true, the year will not be displayed | | has-time | Boolean | false | Whether to show a time component | | classes | String | 'vs-date' | Classes to be applied to the <span> | | locales | String or Array| navigator.languages | The locale to be used for formatting |

Examples

Here are some examples for you to become familiar with our date formatter.

No Props

<date-format :date="1/1/2020" />

Output: 1 January 1970

No days, Short month

<date-format :date="1/1/2020" no-days short-month />

Output:  Jan 2020

Custom Styling

You can also use the classes prop to pass any specific class over to the <span> tag, just on the off chance you need something like that.