Home >Web Front-end >JS Tutorial >Convert Dates to Persian Time in React
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.
Key Features:
Installation:
Install via npm:
<code class="language-bash">npm install persiantime</code>
Or Yarn:
<code class="language-bash">yarn add persiantime</code>
Usage Examples:
Formatting a date:
<code class="language-javascript">import { PersianTime } from 'persiantime'; const persianDate = PersianTime(new Date('2025-01-20T11:05:20.451Z')); console.log(persianDate); // Output: Persian formatted date and time</code>
Handling API dates (ISO format):
<code class="language-javascript">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);</code>
Why Choose PersianTime?
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!