Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Problem to format date
  • Hello, I've a problem with Date::format function i fetch in table a mysql datetime and - before Date::create_from_string : 2012-03-27 17:39:46 - after Date::create_from_string :
    object(Fuel\Core\Date)#29 (2) { ["timestamp":protected]=> int(-1822890014) ["timezone":protected]=> string(15) "Europe/Brussels" }
    

    - after ->format( 'eu_full' ) : 17:39, 27 mars 1912. The years are different after format calling.
    I try to change the timezone but it does not change. somone has an idea to help me ? phil
  • Can you create an issue on Github? Or pull-request? Otherwise I may forget. ("bug reports" as such are only considered official once reported in our Github issue tracker)
  • issue created #892: problem with strptime bug fix for windows
  • Phili ppe wrote on Tuesday 27th of March 2012:
    Hello, I've a problem with Date::format function i fetch in table a mysql datetime and - before Date::create_from_string : 2012-03-27 17:39:46 - after Date::create_from_string :
    object(Fuel\Core\Date)#29 (2) { ["timestamp":protected]=> int(-1822890014) ["timezone":protected]=> string(15) "Europe/Brussels" }
    

    - after ->format( 'eu_full' ) : 17:39, 27 mars 1912. The years are different after format calling.
    I try to change the timezone but it does not change. somone has an idea to help me ? phil

    Interesting Question.
    Date::create_from_string : 2012-03-27 17:39:46 I have made on my PC, I got
    ->format('local',"%m/%d/%y") = 10/07/27 09:20:14 Windows xp sp3, PHP 5.3
    'default_timezone' => 'Europe/Vilnius',
  • Phili ppe wrote on Tuesday 27th of March 2012:
    - before Date::create_from_string : 2012-03-27 17:39:46 - after Date::create_from_string :
    object(Fuel\Core\Date)#29 (2) { ["timestamp":protected]=> int(-1822890014) ["timezone":protected]=> string(15) "Europe/Brussels" }
    

    The problem obviously arises on the original conversion from Date::create_from_string() as the timestamp above is negative (thus before 1970). Are you on windows or linux? What value are you using as the second argument for create_from_string()?
  • I use format 'mysql'
    $test = Date::create_from_string('2012-03-27 17:39:46','mysql');
    
    and i'am on windows.
  • Patterns don't work on windows as noted & explained in the docs http://docs.fuelphp.com/classes/date.html#/method_create_from_string Though mysql timestamps should be accepted without trouble by strtotime() so I'm not sure what's wrong here.
  • I look over the class Fuel\Core\Date and in the bug fix for strptime (for windows support)
    by changing
    'tm_year' => date('y', $ts),
    
    with
    'tm_year' => date('Y', $ts),
    
    to have a full numeric representation of year (4 digits), my problem is revolved

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion