Skip to content

MiladJoodi/PersianTime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PersianTime Library

A simple utility to convert any date or time to Irans's local time with Persian date formatting.

Example Image

Installation

Install the library using npm:

npm install persiantime

or using Yarn:

yarn add persiantime

Usage

Import the persiantime function into your project and use it to convert numbers or strings containing numbers into Persian format.

Example

import { PersianTime } from 'persiantime';

const isoDate = "2025-01-17T03:10:54.225000+03:30";
PersianTime(isoDate)

Function Signature

export function PersianTime(time: string | Date | number): string;

Parameters:

▪ time: Can be a string (ISO 8601 format), Date object, or timestamp (number).

Returns:

▪ A string representing the date and time in Persian format with Iran's local time.

Features

Persian Date: Converts the date to the Persian calendar.
Iran Timezone: Adjusts the time to Iran's local timezone (UTC +03:30).
Handles Invalid Dates: Returns an error message if the provided date is invalid.

License

MIT License

About

A simple utility to convert any date or time to Iran's local time with Persian date formatting. ⭐

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published