persiantime
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

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

Package Sidebar

Install

npm i persiantime

Weekly Downloads

2

Version

1.0.5

License

MIT

Unpacked Size

3.44 kB

Total Files

6

Last publish

Collaborators

  • miladjoodi