Skip to content

Nepali Date PHP - Changelog

List of Changes of all versions of Nepali Date PHP

[1.0.1] - 2026-08-10

Fixed

  • BS Date Off-By-One Near Midnight in Nepal
    • The current Nepali date (new NepaliDate(), or any real DateTimeInterface passed into the constructor) was derived straight from the input's UTC calendar date
    • Since Nepal Standard Time is UTC+05:45, the calendar day rolled over 5 hours 45 minutes late — the BS date showed one day behind actual Nepal time between local midnight and 5:45 AM
    • Added Constants::$NEPAL_UTC_OFFSET_MS; setEnglishDate() now shifts the instant by Nepal's UTC+05:45 offset before computing the day count, matching the NodeJS/Python fix
  • startOfDay() / endOfDay() Round-Trip Bug
    • Previously reconstructed the instance by passing the adjusted timestamp back through the constructor, which could roll the result onto the following BS day now that day derivation is Nepal-offset-aware
    • Now clones the instance and sets the adjusted timestamp directly, so the BS day never changes

Changed

  • getHours() / getMinutes() / getSeconds() / getDay() Now Nepal Local Time
    • Previously computed in plain UTC (a deliberate 1.0.0 design choice, documented in that release's notes, to be deterministic across hosts)
    • All four now apply the explicit Constants::$NEPAL_UTC_OFFSET_MS shift before reading the value with gmdate(), so they report Nepal Standard Time (UTC+05:45) instead of UTC, matching the NodeJS/Python ports
  • startOfDay() / endOfDay() Now Anchor to Nepal Midnight
    • Previously floored to the UTC day boundary; now computes the true UTC instant corresponding to 00:00:00.000 / 23:59:59.999 Nepal local time instead

Migration Notes

  • ⚠️ getHours(), getMinutes(), getSeconds(), getDay(), and startOfDay()/endOfDay() now report Nepal Standard Time (UTC+05:45) instead of UTC (superseding the UTC-based behavior documented in 1.0.0's "Notes on This Port"). getEnglishDate() for startOfDay()/endOfDay() now returns the true Gregorian instant matching Nepal midnight (18:15/18:14:59.999 UTC on the previous/same Gregorian day) rather than 00:00:00/23:59:59.999 UTC — update any code that string-compares or serializes these directly.
  • BS dates derived from the current moment (new NepaliDate(), or any instant within roughly 5 hours 45 minutes of a UTC day boundary) may now report a different, correct day, since day derivation is Nepal-timezone-aware rather than pure UTC.

[1.0.0] - 2026-07-26

Added

  • Initial Release
    • Complete Nepali Date library for PHP, ported 1:1 from the NodeJS implementation
    • Method names, argument order, and validation messages kept identical to the NodeJS port wherever PHP allows it
    • Core NepaliDate class for creating, manipulating, comparing, and formatting Bikram Sambat dates
    • ADtoBS() / BStoAD() conversion functions
    • Date arithmetic (addDays, addMonths, addYears) and comparison (isBefore, isAfter, isEqual, isSame, diff)
    • Day/week/month/year boundary helpers (startOfDay/endOfDay, startOfWeek/endOfWeek, startOfMonth/endOfMonth, startOfYear/endOfYear)
    • Calendar generation via getCalendarDays() for building datepickers
    • Fiscal year and quarter support (getCurrentFiscalYear, getFiscalYearQuarter(s), getQuarter(s))
    • Full Moment.js-style format() token support, including Nepali (Devanagari) output
    • Constants helper class exposing month/weekday names, Nepali numerals, and the raw BS 1976-2100 calendar map

Platform Support

  • Requires PHP 7.1 through 8.5
  • Zero runtime dependencies; installable via Composer as sghimire/nepali-date-library
  • declare(strict_types=1) throughout, with PHPUnit test coverage including a full-range BS↔AD round-trip check for every supported day

Notes on This Port

Because PHP's language rules differ from JavaScript's in a few places, the PHP port makes some deliberate, documented adjustments:

  • Deterministic timezone handling: getDay(), getHours(), getMinutes(), getSeconds(), and all day/week/month/year boundary methods are computed in UTC, unlike the NodeJS port, which reads these from the host machine's local timezone. This keeps results consistent across servers regardless of their configured timezone.
  • isValid() naming: PHP does not allow a static and an instance method to share the same name. The static validator keeps the name NepaliDate::isValid() (matching the NodeJS API exactly); the instance-level check is named isValidInstance() instead.
  • Arrays instead of objects: Methods that return an object with start/end or Q1-Q4 properties in NodeJS/Python (e.g. getQuarter(), getFiscalYearQuarters(), getCalendarDays()) return an associative array with the same keys in PHP.
  • Constants as a class: PHP has no top-level named exports, so MONTH_EN, WEEK_EN, NUMBER_NP, NEPALI_DATE_MAP, and friends are exposed as public static properties on NepaliDateLibrary\Helper\Constants rather than free-standing importable bindings.

Migration Notes

  • ✅ No breaking changes to track yet — this is the library's first release.

Released under the MIT License.