PHPackages                             phstc/jquery-dateformat - 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. phstc/jquery-dateformat

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

phstc/jquery-dateformat
=======================

jQuery Plugin to format Date outputs using JavaScript.

1.0.2(11y ago)67622.3k229[8 issues](https://github.com/phstc/jquery-dateFormat/issues)[10 PRs](https://github.com/phstc/jquery-dateFormat/pulls)1MITJavaScript

Since Jul 2Pushed 2y ago36 watchersCompare

[ Source](https://github.com/phstc/jquery-dateFormat)[ Packagist](https://packagist.org/packages/phstc/jquery-dateformat)[ Docs](https://github.com/phstc/jquery-dateFormat)[ RSS](/packages/phstc-jquery-dateformat/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependenciesVersions (11)Used By (1)

jquery-dateFormat - jQuery Plugin to format Date outputs using JavaScript - ***Having less than 5kb, jquery-dateFormat is the smallest date format library available!***

[![build passing](https://camo.githubusercontent.com/e8d13f12a49cf403f3b6bde1872e6a5b803fb12c05af1d7ea65bf71dd97a0c3c/68747470733a2f2f7472617669732d63692e6f72672f70687374632f6a71756572792d64617465466f726d61742e706e67 "build passing")](http://travis-ci.org/phstc/jquery-dateFormat)

Installation
============

[](#installation)

Download latest jquery.dateFormat.js or jquery.dateFormat.min.js.

- [jquery-dateFormat.js](https://raw.githubusercontent.com/phstc/jquery-dateFormat/master/dist/jquery-dateformat.js)
- [jquery-dateFormat.min.js](https://raw.githubusercontent.com/phstc/jquery-dateFormat/master/dist/jquery-dateformat.min.js)
- [dateFormat.js](https://raw.github.com/phstc/jquery-dateFormat/master/dist/dateFormat.js) (pure Javascript, no jQuery dependency)
- [dateFormat.min.js](https://raw.github.com/phstc/jquery-dateFormat/master/dist/dateFormat.min.js) (pure Javascript, no jQuery dependency)

You can use **jquery-dateFormat without jQuery**. You just need to import the dateFormat.js above and instead of formatting with `$.format(...)` you should use `DateFormat.format(...)`.

If you use **jQuery Validate** plugin you must use jquery-dateFormat without jQuery.

Format patterns
===============

[](#format-patterns)

The patterns to formatting are based on [java.text.SimpleDateFormat](http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html).

Date and time patterns
----------------------

[](#date-and-time-patterns)

- yy = short year
- yyyy = long year
- M = month (1-12)
- MM = month (01-12)
- MMM = month abbreviation (Jan, Feb ... Dec)
- MMMM = long month (January, February ... December)
- d = day (1 - 31)
- dd = day (01 - 31)
- ddd = day of the week in words (Monday, Tuesday ... Sunday)
- E = short day of the week in words (Mon, Tue ... Sun)
- D - Ordinal day (1st, 2nd, 3rd, 21st, 22nd, 23rd, 31st, 4th...)
- h = hour in am/pm (0-12)
- hh = hour in am/pm (00-12)
- H = hour in day (0-23)
- HH = hour in day (00-23)
- mm = minute
- ss = second
- SSS = milliseconds
- a = AM/PM marker
- p = a.m./p.m. marker

Expected input dates formats
============================

[](#expected-input-dates-formats)

- 1982-10-15T01:10:20+02:00
- 1982-10-15T01:10:20Z
- Thu Oct 15 01:10:20 CET 1982
- 1982-10-15 01:10:20.546
- Thu Oct 15 1982 01:10:20 GMT-0800 (PST)
- Thu Oct 15 1982 01:10:20 GMT+0800 (China Standard Time)
- Thu Oct 15 1982 01:10:20 GMT+0200 (W. Europe Daylight Time)
- 1982-10-15CET01:10:20
- JavaScript: new Date().getTime()

[Some examples](https://github.com/phstc/jquery-dateFormat/blob/master/test/format_parse_date_spec.js).

Usage
=====

[](#usage)

```

   document.write($.format.date("2009-12-18 10:54:50.546", "Test: dd/MM/yyyy"));
   document.write($.format.date("Wed Jan 13 10:43:41 CET 2010", "dd~MM~yyyy"));

```

**Output**

```
 => Test: 18/12/2009
 => 13~01~2010

```

Formatting using css classes
----------------------------

[](#formatting-using-css-classes)

```
  2009-12-18 10:54:50.546
  2009-12-18 10:54:50.546
```

```
  jQuery(function() {
      var shortDateFormat = 'dd/MM/yyyy';
      var longDateFormat  = 'dd/MM/yyyy HH:mm:ss';

      jQuery(".shortDateFormat").each(function (idx, elem) {
          if (jQuery(elem).is(":input")) {
              jQuery(elem).val(jQuery.format.date(jQuery(elem).val(), shortDateFormat));
          } else {
              jQuery(elem).text(jQuery.format.date(jQuery(elem).text(), shortDateFormat));
          }
      });
      jQuery(".longDateFormat").each(function (idx, elem) {
          if (jQuery(elem).is(":input")) {
              jQuery(elem).val(jQuery.format.date(jQuery(elem).val(), longDateFormat));
          } else {
              jQuery(elem).text(jQuery.format.date(jQuery(elem).text(), longDateFormat));
          }
      });
  });
```

**Output**

```
 => 18/12/2009
 => 18/12/2009 10:54:50

```

Pretty date formatting
----------------------

[](#pretty-date-formatting)

`jQuery.format.prettyDate(value)` returns a string representing how long ago the date represents

- value = String representing ISO time or date in milliseconds or javascript Date object

```
 jQuery.format.prettyDate(new Date())             // => "just now"
 jQuery.format.prettyDate(new Date().getTime())   // => "just now"
 jQuery.format.prettyDate("2008-01-28T20:24:17Z") // => "2 hours ago"
 jQuery.format.prettyDate("2008-01-27T22:24:17Z") // => "Yesterday"
 jQuery.format.prettyDate("2008-01-26T22:24:17Z") // => "2 days ago"
 jQuery.format.prettyDate("2008-01-14T22:24:17Z") // => "2 weeks ago"
 jQuery.format.prettyDate("2007-12-15T22:24:17Z") // => "more than 5 weeks ago"
```

toBrowserTimeZone
-----------------

[](#tobrowsertimezone)

`jQuery.format.toBrowserTimeZone(value, format)` converts into browsers timezone.

- value = String representing date in ISO time ("2013-09-14T23:22:33Z") or String representing default JAXB formatting of `java.util.Date` ("2013-09-14T16:22:33.527-07:00") or String representing Unix Timestamp (Sat Sep 14 2013 16:22:33 GMT-0700 (PDT)) or javascript date object.
- format = All input formats valid for `jQuery.format.date` are valid for this method. The defaut format is MM/dd/yyyy HH:mm:ss.

### Valid input formats

[](#valid-input-formats)

```
 var date1 = "2013-09-14T23:22:33Z";
 var date2 = "2013-09-14T16:22:33.527-07:00";
 var date3 = "Sat Sep 14 2013 16:22:33 GMT-0700 (PDT)";

 $.format.toBrowserTimeZone(date1)
 $.format.toBrowserTimeZone(date2)
 $.format.toBrowserTimeZone(date3)
```

Development
===========

[](#development)

To compile jquery-dateFormat (generate dist files):

```
npm run compile
```

Testing
-------

[](#testing)

Tests are written using Jasmine. To run the test suite with PhantomJS, run `npm run test`. To run the test suite in your default browser, run `npm run test:browser`.

Licenses
========

[](#licenses)

jquery-dateFormat is released under the [MIT License](http://opensource.org/licenses/MIT).

Do you want to improve jquery-dateFormat
========================================

[](#do-you-want-to-improve-jquery-dateformat)

You're welcome to make your contributions and send them as a pull request.

Contributors
------------

[](#contributors)

Thanks to [all contributors](https://github.com/phstc/jquery-dateFormat/graphs/contributors).

###  Health Score

45

—

FairBetter than 92% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity46

Moderate usage in the ecosystem

Community36

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 59.7% 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

Every ~91 days

Total

2

Last Release

4245d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/105652?v=4)[Pablo Cantero](/maintainers/phstc)[@phstc](https://github.com/phstc)

---

Top Contributors

[![phstc](https://avatars.githubusercontent.com/u/105652?v=4)](https://github.com/phstc "phstc (86 commits)")[![ssproessig](https://avatars.githubusercontent.com/u/1576323?v=4)](https://github.com/ssproessig "ssproessig (7 commits)")[![CJxD](https://avatars.githubusercontent.com/u/1629692?v=4)](https://github.com/CJxD "CJxD (6 commits)")[![arjunballa](https://avatars.githubusercontent.com/u/613351?v=4)](https://github.com/arjunballa "arjunballa (5 commits)")[![buholzer](https://avatars.githubusercontent.com/u/397859?v=4)](https://github.com/buholzer "buholzer (4 commits)")[![dwaxweiler](https://avatars.githubusercontent.com/u/12501775?v=4)](https://github.com/dwaxweiler "dwaxweiler (4 commits)")[![joostory](https://avatars.githubusercontent.com/u/830864?v=4)](https://github.com/joostory "joostory (3 commits)")[![AndreyCarter](https://avatars.githubusercontent.com/u/5441612?v=4)](https://github.com/AndreyCarter "AndreyCarter (2 commits)")[![Dahdread](https://avatars.githubusercontent.com/u/1056098?v=4)](https://github.com/Dahdread "Dahdread (2 commits)")[![jafin](https://avatars.githubusercontent.com/u/127927?v=4)](https://github.com/jafin "jafin (2 commits)")[![jwadhams](https://avatars.githubusercontent.com/u/1613739?v=4)](https://github.com/jwadhams "jwadhams (2 commits)")[![thiloplanz](https://avatars.githubusercontent.com/u/150349?v=4)](https://github.com/thiloplanz "thiloplanz (2 commits)")[![Zyber17](https://avatars.githubusercontent.com/u/187096?v=4)](https://github.com/Zyber17 "Zyber17 (2 commits)")[![hafeyang](https://avatars.githubusercontent.com/u/745503?v=4)](https://github.com/hafeyang "hafeyang (1 commits)")[![tfrajt](https://avatars.githubusercontent.com/u/11228346?v=4)](https://github.com/tfrajt "tfrajt (1 commits)")[![jharting](https://avatars.githubusercontent.com/u/167352?v=4)](https://github.com/jharting "jharting (1 commits)")[![jonathanargentiero](https://avatars.githubusercontent.com/u/1436730?v=4)](https://github.com/jonathanargentiero "jonathanargentiero (1 commits)")[![docchang](https://avatars.githubusercontent.com/u/500922?v=4)](https://github.com/docchang "docchang (1 commits)")[![vejuhust](https://avatars.githubusercontent.com/u/2491781?v=4)](https://github.com/vejuhust "vejuhust (1 commits)")[![merge-when-green[bot]](https://avatars.githubusercontent.com/in/19479?v=4)](https://github.com/merge-when-green[bot] "merge-when-green[bot] (1 commits)")

---

Tags

dateformat

### Embed Badge

![Health badge](/badges/phstc-jquery-dateformat/health.svg)

```
[![Health](https://phpackages.com/badges/phstc-jquery-dateformat/health.svg)](https://phpackages.com/packages/phstc-jquery-dateformat)
```

###  Alternatives

[laravel-admin-ext/config

Config extension for laravel-admin

97180.2k5](/packages/laravel-admin-ext-config)

PHPackages © 2026

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