MaplePHP
  • MaplePHP - Layered structure MVC PHP framework
  • Guide
    • Get started
    • Installation
    • Service Provider
    • Dependency injector
    • Controller
    • Middlewares
    • Routers
  • Navigation
    • Simple navigation
    • Dynamic navigation
  • Template engine
    • Getting started
    • Templates
      • Index
      • Views
      • Partials
    • Content (DTO)
      • String
      • Number
      • Array
      • DateTime
      • Encode
      • Dom
  • Form builder
    • Form builder
  • Database
    • MySQL
  • Service providers
    • url
    • encode
    • dir
    • DB
    • responder
  • Installations
    • Authorization & login
  • Frontend template
    • Responder
    • Views & components
    • Modals
    • Redirects
  • Access
    • MaplePHP with Docker
  • Libraries
    • Container
    • MySQL queries
    • Validation
    • Cache
    • Logger
    • Request
    • Response
  • What is?
    • Dependency injector
    • Controller
    • Middleware
    • Router
Powered by GitBook
On this page
  • MaplePHP Format Date Class with Translations Library
  • Date Formatting Methods
  • Translation Methods
  • Utility Methods
  • Magic Methods
  • Constants

Was this helpful?

  1. Template engine
  2. Content (DTO)

DateTime

MaplePHP Format Date Class with Translations Library

This PHP library, named MaplePHP\DTO\Format\DateTime, extends the DateTime class and provides additional functionality for formatting dates with translations. Below is a guide to the methods available in this library.

Date Formatting Methods

format(string $format): string

  • Formats the date according to the specified format and translates month and day names.

  • Parameters:

    • $format: The format string.

  • Returns:

    • The formatted date string.

Translation Methods

getTranslations(): array

  • Gets all acceptable translation data.

  • Returns:

    • An array of translation data.

setTranslation(string $key, array $arr): self

  • Creates or updates a translation for a specific language key.

  • Parameters:

    • $key: Language key.

    • $arr: Array of translations.

  • Returns:

    • An instance of the date format.

setLanguage(string $lang): self

  • Changes the expected language for translations.

  • Parameters:

    • $lang: Language key.

  • Returns:

    • An instance of the date format.

  • Throws:

    • Exception if the translation for the specified language does not exist.

Utility Methods

clone(): self

  • Creates a clone of the current date format instance.

  • Returns:

    • A new instance of the date format.

withValue(string $value): self

  • Creates a new instance of the date format with a different date value.

  • Parameters:

    • $value: The new date value.

  • Returns:

    • A new instance of the date format.

Magic Methods

__toString(): string

  • Gets the string representation of the date in the format "Y/m/d H:i".

__unserialize(array $data): void

  • Unserializes the data for the date format.

Constants

DEFAULT_LANG

  • Default language key.

LANG

  • Array of month, day, and weekday name translations for different languages.

PreviousArrayNextEncode

Last updated 1 year ago

Was this helpful?