Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel carbon createFromFormat adding 1 year

Tags:

php

laravel-4

I´m trying to use carbon for use diffInMinutes, that works great, but before I do this I convert my timestamp in carbon format I do:

$teste= '2014-12-12 15:00:00';

$entrada = Carbon::createFromFormat('Y-m-d H:m:s', $teste);

but when I dd($teste, $entrada):

string '2014-12-12 15:00:00' (length=19)

object(Carbon\Carbon)[340]
  public 'date' => string '2013-12-12 15:00:00' (length=19)
  public 'timezone_type' => int 3
  public 'timezone' => string 'America/Sao_Paulo' (length=17)

anyone knows how fix this??? thx in advance

like image 257
Lucas Campos Avatar asked Jun 12 '26 12:06

Lucas Campos


1 Answers

I don't know if this is the issue but your date format should be

'Y-m-d H:i:s' not 'Y-m-d H:m:s'

Date format reference

like image 199
Ronnie Avatar answered Jun 14 '26 00:06

Ronnie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!