Skip to content

Instantly share code, notes, and snippets.

@stursby
Created March 8, 2015 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stursby/10ca27c81353625df4ea to your computer and use it in GitHub Desktop.
Save stursby/10ca27c81353625df4ea to your computer and use it in GitHub Desktop.
fightbulc/moment incorrect month format demo
  1. Create a folder & cd into that folder.
  2. Install Composer or curl -sS https://getcomposer.org/installer | php
  3. Install packages php composer.phar install
  4. Run the app php app.php

Sample Output

2015-03-08T15:14:53-0500 // correct
Sunday, 08th April 2015 / 15:14 (America/Chicago) // wrong month
Sunday, 08th March 2015 / 15:14 (America/Chicago) // correct month
<?php
require 'vendor/autoload.php';
date_default_timezone_set('America/Chicago');
// Using Moment -- https://github.com/fightbulc/moment.php
$m = new \Moment\Moment('now', 'CST');
// Correct month 03 (March)
echo $m->format() . "\n";
// Wrong month, says "April"
echo $m->format('l, dS F Y / H:i (e)') . "\n";
// Using plain php date -- http://php.net/manual/en/function.date.php
// Correct month March
$date = date('l, dS F Y / H:i (e)');
echo $date . "\n";
{
"require": {
"fightbulc/moment": "~1.7"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment