Home > Web Front-end > JS Tutorial > Convert Dates to Persian Time in React

Convert Dates to Persian Time in React

Linda Hamilton
Release: 2025-01-27 22:35:10
Original
599 people have browsed it

PersianTime: Your Go-To JavaScript Library for Iranian Time and Date Formatting

This lightweight utility effortlessly converts any date or time to Iran's local time, displaying it in the familiar Persian date format. Ideal for applications targeting Iranian users or those needing seamless Persian calendar integration.

Convert Dates to Persian Time in React

Key Features:

  • Precise conversion to Iran Standard Time (UTC 3:30).
  • User-friendly Persian date formatting.
  • Simple API for quick integration into JavaScript and TypeScript projects.

Installation:

Install via npm:

npm install persiantime
Copy after login

Or Yarn:

yarn add persiantime
Copy after login

Usage Examples:

Formatting a date:

import { PersianTime } from 'persiantime';

const persianDate = PersianTime(new Date('2025-01-20T11:05:20.451Z'));
console.log(persianDate); // Output: Persian formatted date and time
Copy after login

Handling API dates (ISO format):

import { PersianTime } from 'persiantime';

const creationTime = PersianTime(new Date(document.created_at));
const updateTime = PersianTime(new Date(document.updated_at));

console.log(creationTime);
console.log(updateTime);
Copy after login

Why Choose PersianTime?

  • Accuracy: Guarantees correct Iran Standard Time conversion.
  • Ease of Use: Seamless integration into JavaScript and TypeScript projects.
  • Efficiency: Minimal dependencies for a lightweight solution.

Contributing:

We welcome contributions! Fork the repository, make your improvements, and submit pull requests. Report issues or suggest features on the GitHub repository.

Show Your Support:

Star the project on GitHub and leave a review on npm to help us continue development and add new features.

Links:

Thank you for using PersianTime!

The above is the detailed content of Convert Dates to Persian Time in React. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template