PHPackages                             battye/date-convert - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. battye/date-convert

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

battye/date-convert
===================

Convert a date string from one format to another.

v1.0.0(6y ago)05MITPHPPHP &gt;=5.3.3

Since Aug 25Pushed 6y ago1 watchersCompare

[ Source](https://github.com/battye/date-convert)[ Packagist](https://packagist.org/packages/battye/date-convert)[ RSS](/packages/battye-date-convert/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Date Convert
============

[](#date-convert)

A small library which uses the `DateTime` object to convert a date string from one format to another.

Installation
------------

[](#installation)

Install this library with composer, using the command `composer require battye/date-convert "~1.0"`. If you notice any bugs, please raise an issue or pull request.

### Simple Usage

[](#simple-usage)

The original date string must be supplied in the `date()` function.

The `from()` function should be used to indicate the format being used, while `to()` should be filled with the desired output format (in conjunction with `datetext()`).

An example usage is shown below:

```
use battye\date_convert\convert;

$convert = convert::date('2011-01-20 00:00:00+09')
    ->from('Y-m-d H:i:sT')
    ->to('j F y');

$datetime = $convert->datetime(); // returns a DateTime object
$datetext = $convert->datetext(); // returns 20 January 11
$timestamp = $convert->timestamp(); // returns 1295449200

```

### Converting Timezones

[](#converting-timezones)

To output a format in a different timezone, it can be specified in either of the following ways prior to calling `datetime()` or `datetext()`. Timestamps are not impacted by timezone.

```
$convert->timezone(new \DateTimeZone('Asia/Macau'));
$convert->timezone('Asia/Macau');

```

Tests
-----

[](#tests)

[![Build Status](https://camo.githubusercontent.com/711a3768c880522441286f127849246a7c063dad877950209527068154765f49/68747470733a2f2f7472617669732d63692e636f6d2f6261747479652f646174652d636f6e766572742e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/battye/date-convert)

The unit tests provide good examples of how to utilise this library and can be found in the `tests/` directory. To execute the unit tests, run:

```
vendor/bin/simple-phpunit tests/

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2453d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b9ce1e69218256bc4ba5f74f39ecac1548761472e323898c5622170af7d6b49?d=identicon)[battye](/maintainers/battye)

---

Top Contributors

[![battye](https://avatars.githubusercontent.com/u/2110222?v=4)](https://github.com/battye "battye (1 commits)")

---

Tags

datedatetimephpphpformatdate

### Embed Badge

![Health badge](/badges/battye-date-convert/health.svg)

```
[![Health](https://phpackages.com/badges/battye-date-convert/health.svg)](https://phpackages.com/packages/battye-date-convert)
```

###  Alternatives

[kartik-v/yii2-datecontrol

Date control module allowing separation of formats for View and Model for Yii Framework 2.0

551.5M36](/packages/kartik-v-yii2-datecontrol)[dater/dater

Compact PHP library for working with date/time in different formats &amp; timezones.

14282.3k](/packages/dater-dater)[zjkal/time-helper

一个简单快捷的PHP日期时间助手类库。 a smart PHP datetime helper library.

21128.6k1](/packages/zjkal-time-helper)[maherelgamil/arabicdatetime

Easy and useful tool to generate arabic or hijri date with multi-language support for laravel

414.5k](/packages/maherelgamil-arabicdatetime)[indieweb/date-formatter

Render dates and date ranges in a human-readable format, including proper microformats-2 markup

1919.7k](/packages/indieweb-date-formatter)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
