Installation

NPM

            
npm i @alireza-ab/persian-date
            
        

Import and usage

                
import PersianDate from '@alireza-ab/persian-date'

let p = new PersianDate();
                
            
OR
            
const PersianDate = require('@alireza-ab/persian-date')

let p = new PersianDate();
            
        

Nuxt 2.2.0+

            
npm i @alireza-ab/persian-date
            
        

Add to the buildModules section of nuxt.confing.js:

                
export default {
    buildModules: {
        '@alireza-ab/persian-date/nuxt'
    }
}
                
            

If you are using Nuxt < v2.9, you have to use modules section in nuxt.config.js instead of buildModules.

Usage

The $PersianDate is an instance of PersianDate modules and you not must use it with new keyword.

            
<div v-text="$PersianDate.toString()"></div>
<div>{{ $PersianDate.toString() }}</div>
            
        
            
mounted() {
    this.date = this.$PersianDate.clone().month(5).toString();
}
            
        

CDN

This package is availabe on jsdelivery and unpkg

            
<script src="https://cdn.jsdelivr.net/npm/@alireza-ab/persian-date@2.6.0/dist/PersianDate.umd.min.js"></script>
            
        
OR
            
<script src="https://unpkg.com/@alireza-ab/persian-date@2.6.0/dist/PersianDate.umd.min.js"></script>
            
        

Example

            
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>app</title>
</head>
<body>

    <script src="https://cdn.jsdelivr.net/npm/@alireza-ab/persian-date@2.6.0/dist/PersianDate.umd.min.js"></script>
    <script>
        let p = new PersianDate();
    </script>
</body>
</html>
            
        

Download

Dist files

Nodejs 36.44kB
Browser 36.65kB

Source files

Download 173.78kB