Download the PHP package effectra/clock without Composer

On this page you can find all versions of the php package effectra/clock. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package clock

Effectra\Clock

Effectra\Clock is a lightweight PHP utility class that implements Psr\Clock\ClockInterface. It provides common date and time helpers for applications, including formatting, date arithmetic, calendar checks, timezone management, and basic Hijri calendar support.

Features

Usage

Public methods

now(): \DateTimeImmutable

Returns the current date and time as a DateTimeImmutable object.

timestamp(): int

Returns the current Unix timestamp as an integer.

format(string $format = 'Y-m-d H:i:s'): string

Formats the current date and time using the provided PHP date format string.

date(string $format = 'Y-m-d'): string

Returns the current date only, formatted with the supplied format.

time(string $format = 'H:i:s'): string

Returns the current time only, formatted with the supplied format.

dayOfWeek(bool $short = false): string

Returns the current day of the week. If $short is true, it returns the short form such as Mon; otherwise it returns the full name such as Monday.

month(bool $short = false): string

Returns the current month name. If $short is true, it returns the abbreviated month name.

year(): int

Returns the current year as an integer.

isLeapYear(): bool

Checks whether the current year is a leap year.

daysInMonth(): int

Returns the number of days in the current month.

toTimestamp(string $dateTime): int

Converts a date string into a Unix timestamp.

add(string $interval, int $value = 1): \DateTimeImmutable

Adds a time interval to the current time. Example: add('days', 2).

sub(string $interval, int $value = 1): \DateTimeImmutable

Subtracts a time interval from the current time.

diff(string $date1, string $date2, string $format = '%a days'): string

Calculates the difference between two dates and formats it using the supplied DateInterval format string.

toHijri(?int $year = null, ?int $month = null, ?int $day = null, bool $arabicNames = true): array

Converts a Gregorian date to Hijri date data. If no year, month, or day is provided, it uses the current date. The result includes the Hijri year, month, day, month name, day of year, leap-year flag, and formatted strings.

hijriNow(bool $arabicNames = true): array

Returns the current Hijri date information using the same structure as toHijri().

hijriFormat(string $format = 'd F Y', bool $arabicNames = true): string

Formats the current Hijri date using a simplified token format such as d, j, F, M, m, n, Y, and y.

timezoneInfo(): array

Returns information about the current timezone, including the timezone name, offset in seconds, offset in hours, and whether daylight saving time is active.

setTimezone(string $timezone): bool

Sets the default timezone and returns whether the operation succeeded.

microtime(): float

Returns the current timestamp with microseconds precision.

formatTimestamp(?int $timestamp = null, string $format = 'Y-m-d H:i:s'): string

Formats a Unix timestamp into a readable string. If no timestamp is provided, the current timestamp is used.

isWeekend(?string $date = null): bool

Checks whether the provided date is a weekend. If no date is given, it uses the current date.

dayBoundaries(?string $date = null): array

Returns the start and end of the day for a given date, along with their Unix timestamps.

Example

Contributing

Contributions are welcome. If you find a bug or want to suggest an improvement, feel free to open an issue or submit a pull request.

License

This package is open-source and available under the MIT License. "# clock"


All versions of clock with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0.2
psr/clock Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package effectra/clock contains the following files

Loading the files please wait ...