<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: zjkal</title>
    <description>The latest articles on DEV Community by zjkal (@zjkal).</description>
    <link>https://dev.to/zjkal</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1305514%2F596d2651-441e-4754-94d7-4211cc78d3ad.jpeg</url>
      <title>DEV Community: zjkal</title>
      <link>https://dev.to/zjkal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zjkal"/>
    <language>en</language>
    <item>
      <title>📝Github Notes - a browser extension for adding private notes to GitHub</title>
      <dc:creator>zjkal</dc:creator>
      <pubDate>Sat, 16 Aug 2025 11:55:21 +0000</pubDate>
      <link>https://dev.to/zjkal/github-notes-a-browser-extension-for-adding-private-notes-to-github-1c8</link>
      <guid>https://dev.to/zjkal/github-notes-a-browser-extension-for-adding-private-notes-to-github-1c8</guid>
      <description>&lt;h2&gt;
  
  
  📝 Overview
&lt;/h2&gt;

&lt;p&gt;GitHub Notes is a lightweight browser extension that allows you to add private, personal notes to any GitHub repository. Enhance your code management experience with persistent, local notes that help you remember important details about repositories you work with.&lt;/p&gt;

&lt;h2&gt;
  
  
  ✨ Features
&lt;/h2&gt;

&lt;h3&gt;
  
  
  🎯 Core Functionality
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Private Notes&lt;/strong&gt;: Add personal notes to any GitHub repository&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real-time Editing&lt;/strong&gt;: Click to edit with instant save functionality&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local Storage&lt;/strong&gt;: All data stored locally for privacy protection&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cross-tab Sync&lt;/strong&gt;: Notes sync across browser tabs in real-time&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Integration&lt;/strong&gt;: Seamlessly integrates with GitHub's interface&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🌍 Multi-language Support
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;English &amp;amp; Chinese&lt;/strong&gt;: Full interface localization&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto Detection&lt;/strong&gt;: Automatically detects browser language&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  📊 Data Management
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Import/Export&lt;/strong&gt;: JSON format data backup and restore&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Search Function&lt;/strong&gt;: Quickly find notes by content&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Statistics&lt;/strong&gt;: View note counts and usage statistics&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Privacy&lt;/strong&gt;: No cloud sync, all data stays local&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🎨 User Experience
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub-style UI&lt;/strong&gt;: Perfectly matches GitHub's design language&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Responsive Design&lt;/strong&gt;: Works on all screen sizes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dark Mode&lt;/strong&gt;: Automatic theme adaptation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keyboard Shortcuts&lt;/strong&gt;: Efficient note management&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🚀 Installation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Method: Browser Extension Store
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Chrome&lt;/strong&gt;: &lt;a href="https://chromewebstore.google.com/detail/github-notes/mejhlipglijbkcfcnljjdcdngafbbheo" rel="noopener noreferrer"&gt;Install from Chrome Web Store&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Edge&lt;/strong&gt;: &lt;a href="https://microsoftedge.microsoft.com/addons/detail/github-notes/kjecncpipakdbomdpagliljcaomojjbk" rel="noopener noreferrer"&gt;Install from Microsoft Edge Add-ons&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;github: &lt;a href="https://github.com/zjkal/github-notes" rel="noopener noreferrer"&gt;https://github.com/zjkal/github-notes&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>a smart PHP datetime helper library</title>
      <dc:creator>zjkal</dc:creator>
      <pubDate>Tue, 27 Feb 2024 02:59:23 +0000</pubDate>
      <link>https://dev.to/zjkal/a-smart-php-datetime-helper-library-4icl</link>
      <guid>https://dev.to/zjkal/a-smart-php-datetime-helper-library-4icl</guid>
      <description>&lt;p&gt;&lt;code&gt;TimeHelper&lt;/code&gt; is a simple and user-friendly &lt;code&gt;PHP Date and Time Helper Library&lt;/code&gt; that enables quick implementation of common date and time operations. It includes functionalities such as getting the number of seconds from a specified time, obtaining a user-friendly time format, checking time ranges, calculating the difference between two times, and providing timestamps for N hours/days/weeks/months/years ago or in the future, among other features.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧩Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Easy to use: It does not rely on any extensions and is ready to use out of the box.&lt;/li&gt;
&lt;li&gt;Simplicity through complexity reduction: All methods can accept &lt;code&gt;either arbitrary date and time formats&lt;/code&gt; or &lt;code&gt;timestamps&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Quick and efficient: All operations can be accomplished with just &lt;code&gt;one static method&lt;/code&gt; for each.&lt;/li&gt;
&lt;li&gt;Long-term maintenance: The author is a freelancer committed to ensuring the project's &lt;code&gt;long-term stability&lt;/code&gt; and &lt;code&gt;continuous updates&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🚀Installation
&lt;/h2&gt;

&lt;p&gt;Install via Composer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;composer require zjkal/time-helper
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🌈Usage
&lt;/h2&gt;

&lt;p&gt;Check the &lt;a href="https://time.0x1.site/en/"&gt;Documentation&lt;/a&gt; or read the brief instructions below&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Get the required number of seconds.
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;This is usually used for setting cache expiration time, setting end time, and so on.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;//Return the number of seconds before midnight tonight.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;secondEndToday&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;//Return the number of seconds for N minutes (default is 1 minute).&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;secondMinute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Return the number of seconds for N hours (default is 1 hour).&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;secondHour&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Return the number of seconds for N days (default is 1 day).&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;secondDay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Return the number of seconds for N weeks (default is 1 week).&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;secondWeek&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Return a friendly date format, such as N seconds ago, N minutes ago, N hours ago, and so on.
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;This is usually used for social media platforms, comments, forums, and so on.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;//There are two parameters:&lt;/span&gt;
&lt;span class="c1"&gt;//The first parameter can be either a string representing a date/time or a timestamp.&lt;/span&gt;
&lt;span class="c1"&gt;//The second parameter is the language (default is Chinese; pass in "en" for English).&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;toFriendly&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'2022-3-2 10:15:33'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;//English&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;toFriendly&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1646186290&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'en'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Determine if a date/time falls within a certain range.
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;//Determine if a date is today.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;isToday&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'2020-4-10 23:01:11'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Determine if a date is this week.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;isThisWeek&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'2020-5-1'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Determine if a date is this month.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;isThisMonth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1586451741&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Determine if a date is this year.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;isThisYear&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Apr 11, 2020'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Determine the day of the week for a given time. If no time is passed in, the current time is used. Returns a value from 1 to 7, where 1 is Monday and 7 is Sunday.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;getWeekDay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'2022-11-27'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Determine if a given time is a weekday (Monday through Friday).&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;isWeekday&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'2023-03-08'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Determine if a given time is a weekend day (Saturday or Sunday).&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;isWeekend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1586451741&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Calculate the difference between two dates/times.
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;If only one parameter is passed in, it will be compared to the current time.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;//Calculate the difference in days between two dates.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;diffDays&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'2022-4-10 23:01:11'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'Apr 11, 2020'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Calculate the difference in weeks between two dates.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;diffWeeks&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'2022-4-10 23:01:11'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Calculate the difference in months between two dates.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;diffMonths&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1586451741&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'Apr 11, 2020'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Calculate the difference in years between two dates.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;diffYears&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'2022-4-10 23:01:11'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'Apr 11, 2020'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Compare two times. If the second parameter is empty, compare it with the current time.&lt;/span&gt;
&lt;span class="c1"&gt;//If the first time is greater than the second time, 1 is returned, if it is less than -1, and if they are equal, 0 is returned.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;compare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'2022-4-10 23:01:11'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'Apr 11, 2020'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Return the timestamp of N hours/days/weeks/months/years ago or in the future.
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;If only one argument is passed, the calculation will be based on the current time. If a second argument is passed, the calculation will be based on that time. If the third argument is set to true, the calculated time will be rounded to the nearest integer.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;//Return the timestamp of 0 seconds 3 minutes ago from the specified time.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;beforeMinute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'2022-3-2 10:15:33'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Return the timestamp of 5 minutes after the current time.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;afterMinute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Return the timestamp of 1 hour before the specified time (Note: This usage is only available in PHP 8 or later).&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;beforeHour&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="s1"&gt;'Apr 11, 2020'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Return the timestamp of 2 hours later.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;afterHour&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Return the timestamp of 0 o'clock 15 days ago.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;beforeDay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Return the timestamp of 15 days later.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;afterDay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Return the timestamp of 2 weeks ago from the specified time.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;beforeWeek&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'2022-4-10 23:01:11'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Return the timestamp for 10 weeks after the specified time&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;afterWeek&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1646360133&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Return the timestamp of 1 month before the specified time (Note that this usage is for PHP 8 or later)&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;beforeMonth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;1646360133&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Return the timestamp 5 months from now&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;afterMonth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Return the timestamp of 3 years ago from the specified time.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;beforeYear&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'2022-7-11'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Return the timestamp of 2 years later.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;afterYear&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6.Get the current timestamp in seconds/milliseconds/microseconds/nanoseconds.
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Generating an order number or interfacing with other programming languages may require this.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;//Get the timestamp in seconds. You can use time() instead.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;getTimestamp&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;//Get the millisecond-level timestamp.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;getMilliTimestamp&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;//Get microsecond-level timestamp.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;getMicroTimestamp&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;//Get the timestamp in nanoseconds.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;getNanoTimestamp&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7.Date Conversion
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;This function is used for converting date format when crawling web pages or integrating with third-party programs with inconsistent date formats.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;//Convert any format of time to a specified format.&lt;/span&gt;
&lt;span class="c1"&gt;//The first parameter is the format of the time, consistent with the format of the system function date().&lt;/span&gt;
&lt;span class="c1"&gt;//The second parameter is the format of the time, which should be consistent with the format of the date() function. The second parameter is any format of the date and time. If not passed, it defaults to the current time, which can be replaced by the date() function.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Y-m-d H:i:s'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'May 3, 2022'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Check if a string is a timestamp, return true if it is, false if it is not.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;isTimestamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1646360133&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Convert any time string to a timestamp.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;toTimestamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Apr 11, 2020'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8.Leap year calculation
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;More convenient to use than native methods.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;//Determine whether it is a leap year, return true if it is, false if it is not.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;isLeapYear&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'2020-3-2 10:15:33'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Determine how many days the year of the given date has.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;daysInYear&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1646360133&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Determine how many days the current month of the given date has.&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;daysInMonth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Apr 11, 2020'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9.Time zone related 🆕
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;It mainly provides methods for obtaining time in different time zones and converting time in different time zones&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;//Converts a time or timestamp in any format to a time in the specified time zone&lt;/span&gt;
&lt;span class="c1"&gt;//The first parameter is the target time zone to convert&lt;/span&gt;
&lt;span class="c1"&gt;//The second parameter is the original time zone, if not passed, it defaults to the current time zone&lt;/span&gt;
&lt;span class="c1"&gt;//The third parameter is a time or timestamp in any format, if not passed, it defaults to the current time&lt;/span&gt;
&lt;span class="c1"&gt;//The fourth parameter is the time format, which is consistent with the format of the system function date(). If not passed, the default is Y-m-d H:i:s&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;timezoneFormat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Europe/London'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Asia/Shanghai'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'2023-8-15 19:16:43'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'H:i:s'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;//Get the current time in Los Angeles&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;timezoneFormat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'America/Los_Angeles'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;//Convert Los Angeles Time to London Time&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;timezoneFormat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Europe/London'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'America/Los_Angeles'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Aug 15, 2023 10:15:33'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'H:i:s'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;//Convert timestamp to London time&lt;/span&gt;
&lt;span class="nc"&gt;TimeHelper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;timezoneFormat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Europe/London'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1692097543&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the list of supported time zones, please refer&lt;br&gt;
to &lt;a href="https://www.php.net/manual/en/timezones.php"&gt;List of Supported Timezones&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  10.Chinese holiday/workday related 🔥
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;This is a function specifically designed for judging Chinese holidays. It currently includes holiday data from 2020 to 2024 and will be continuously updated in the future.&lt;/em&gt;&lt;br&gt;
&lt;em&gt;For the convenience of maintenance, a separate class ChinaHoliday is created, which can also accept any type of time format or timestamp as input.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;zjkal\ChinaHoliday&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;//Determine if the specified date is a working day in China.&lt;/span&gt;
&lt;span class="nc"&gt;ChinaHoliday&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;isWorkday&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'2023-01-23'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Determine if the specified date is a Chinese holiday.&lt;/span&gt;
&lt;span class="nc"&gt;ChinaHoliday&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;isHoliday&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1646360133&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Special Notes&lt;/strong&gt;: All time-related methods can accept time in any format or timestamp. However, please note that for dates in the format of m/d/y or d-m-y, if the separator is a slash (/), the American m/d/y format is used. If the separator is a hyphen (-) or a dot (.), the European d-m-y format is used. To avoid potential errors, it is recommended to use the YYYY-MM-DD format or other formats as much as possible.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  📖License
&lt;/h2&gt;

&lt;p&gt;The MIT License (MIT). Please see &lt;a href="https://github.com/zjkal/time-helper/blob/main/LICENSE"&gt;License File&lt;/a&gt; for more information.&lt;/p&gt;

&lt;p&gt;Github:&lt;a href="https://github.com/zjkal/time-helper"&gt;https://github.com/zjkal/time-helper&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>composer</category>
      <category>time</category>
      <category>helper</category>
    </item>
  </channel>
</rss>
