Call in exactly the same way as you do the "date" command in PHP
e.g. s = $.PHPDate("l, jS F Y", dtDate);
PHPDate 1.0 jQuery Plugin
Copyright (c) 2008 Jon Combe (http://joncom.be)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
var aDays = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
var aMonths = ["January","February","March","April","May","June","July","August","September","October","November","December"];
$.PHPDate = function(sString, dtDate) {
// we can cheat with "r"...
sString = sString.replace(/r/g, "D, j M Y H;i:s O");
for (var i = 0; i < sString.length; i++) {
sElement = sString.charAt(i);
case "a": sElement = AMPM(dtDate.getHours()); break;
sElement = (dtDate.getFullYear() + "-" +
AddLeadingZero(dtDate.getMonth()) + "-" +
AddLeadingZero(dtDate.getDate()) + "T" +
AddLeadingZero(dtDate.getHours()) + ":" +
AddLeadingZero(dtDate.getMinutes()) + ":" +
AddLeadingZero(dtDate.getSeconds()));
var sTemp = dtDate.toString().split(" ")[5];
if (sTemp.indexOf("-") > -1) {
sElement += sTemp.substr(sTemp.indexOf("-"));
} else if (sTemp.indexOf("+") > -1) {
sElement += sTemp.substr(sTemp.indexOf("+"));
case "d": sElement = AddLeadingZero(dtDate.getDate()); break;
case "g": sElement = TwelveHourClock(dtDate.getHours()); break;
case "h": sElement = AddLeadingZero(TwelveHourClock(dtDate.getHours())); break;
case "i": sElement = AddLeadingZero(dtDate.getMinutes()); break;
case "j": sElement = dtDate.getDate(); break;
case "l": sElement = aDays[dtDate.getDay()]; break;
case "m": sElement = AddLeadingZero(dtDate.getMonth() + 1); break;
case "n": sElement = dtDate.getMonth() + 1; break;
case "o": (new Date(FirstMonday(dtDate.getFullYear())) > dtDate) ? sElement = (dtDate.getFullYear() - 1) : sElement = dtDate.getFullYear(); break;
case "s": sElement = AddLeadingZero(dtDate.getSeconds()); break;
var dtTemp = new Date(dtDate.valueOf());
dtTemp.setMonth(dtTemp.getMonth() + 1)
sElement = dtTemp.getDate();
case "u": sElement = dtDate.getMilliseconds(); break;
case "w": sElement = dtDate.getDay(); break;
case "y": sElement = dtDate.getFullYear().toString().substr(2, 2); break;
var dtFirst = new Date(dtDate.getFullYear(), 0, 1, 0, 0, 0, 0);
var dtLast = new Date(dtDate.getFullYear(), dtDate.getMonth(), dtDate.getDate(), 0, 0, 0, 0);
sElement = Math.round((dtLast.valueOf() - dtFirst.valueOf()) / 1000 / 60 / 60/ 24);
case "A": sElement = AMPM(dtDate.getHours()).toUpperCase(); break;
sElement = Math.floor(((dtDate.getHours() * 60 * 60 * 1000) +
(dtDate.getMinutes() * 60 * 1000) +
(dtDate.getSeconds() * 1000) +
(dtDate.getMilliseconds())) / 86400);
case "D": sElement = aDays[dtDate.getDay()].substr(0, 3); break;
case "F": sElement = aMonths[dtDate.getMonth()]; break;
case "G": sElement = dtDate.getHours(); break;
case "H": sElement = AddLeadingZero(dtDate.getHours()); break;
var dtTempFirst = new Date(dtDate.getFullYear(), 0, 1);
var dtTempLast = new Date(dtDate.getFullYear(), dtDate.getMonth(), dtDate.getDate());
var iDaysDiff = (dtTempLast.valueOf() - dtTempFirst.valueOf()) / 1000 / 60 / 60 / 24;
(iDaysDiff == Math.round(iDaysDiff)) ? sElement = 0 : sElement = 1;
case "L": ((new Date(dtDate.getFullYear(), 2, 0)).getDate() == 29) ? sElement = 1 : sElement = 0; break;
case "M": sElement = aMonths[dtDate.getMonth()].substr(0, 3); break;
case "N": (dtDate.getDay() == 0) ? sElement = 7 : sElement = dtDate.getDay(); break;
var sTemp = dtDate.toString().split(" ")[5];
if (sTemp.indexOf("-") > -1) {
sElement = sTemp.substr(sTemp.indexOf("-"));
} else if (sTemp.indexOf("+") > -1) {
sElement = sTemp.substr(sTemp.indexOf("+"));
var sTemp = dtDate.toString().split(" ")[5];
if (sTemp.indexOf("-") > -1) {
var aTemp = sTemp.substr(sTemp.indexOf("-") + 1).split("");
sElement = ("-" + aTemp[0] + aTemp[1] + ":" + aTemp[2] + aTemp[3]);
} else if (sTemp.indexOf("+") > -1) {
var aTemp = sTemp.substr(sTemp.indexOf("+") + 1).split("");
sElement = ("+" + aTemp[0] + aTemp[1] + ":" + aTemp[2] + aTemp[3]);
case "S": sElement = DateSuffix(dtDate.getDate()); break;
sElement = dtDate.toString().split(" ")[5];
if (sElement.indexOf("+") > -1) {
sElement = sElement.substr(0, sElement.indexOf("+"));
} else if (sElement.indexOf("-") > -1) {
sElement = sElement.substr(0, sElement.indexOf("-"));
case "U": sElement = Math.floor(dtDate.getTime() / 1000); break;
var dtTempFirst = new Date(FirstMonday(dtDate.getFullYear()));
var dtTempLast = new Date(dtDate.getFullYear(), dtDate.getMonth(), dtDate.getDate());
sElement = Math.ceil(Math.round((dtTempLast.valueOf() - dtTempFirst.valueOf()) / 1000 / 60 / 60/ 24) / 7);
case "Y": sElement = dtDate.getFullYear(); break;
(dtDate.getTimezoneOffset() < 0) ? sElement = Math.abs(dtDate.getTimezoneOffset() * 60) : sElement = (0 - (dtDate.getTimezoneOffset() * 60));
sOutput += sElement.toString();
function AddLeadingZero(iValue) {
// Ante meridiem and Post meridiem
function DateSuffix(iDay) {
switch (parseInt(iDay)) {
// find the first Monday in a given year (for ISO 8601 dates)
function FirstMonday(iYear) {
var dtTemp = new Date(iYear, 0, 1);
while (dtTemp.getDay() != 1) {
dtTemp.setDate(dtTemp.getDate() + 1);
function TwelveHourClock(iHours) {
} else if (iHours > 12) {