1

I have a problem with my conversion. I don't understand where is my problem, because normally all will be work, So my conversion doesn't work.

$sEndDateFilter is 27/03/2015 23:59:59

When I tried to convert:

$iEndDateFilter = strtotime($sEndDateFilter);

my $iEndDateFilter is vide

Help me please.

Owais Alam
  • 287
  • 1
  • 9
  • 13
Harea Costea
  • 275
  • 5
  • 19
  • try something like this: strtotime(str_replace('/', '-', '27/05/1990')); – miglio Dec 10 '14 at 13:58
  • 1
    This appears to be your solution: http://stackoverflow.com/questions/2891937/strtotime-doesnt-work-with-dd-mm-yyyy-format – Naomi Dec 10 '14 at 13:59
  • 1
    RTFM: http://php.net/strtotime 2nd last note> "Dates in the m/d/y or d-m-y formats are disambiguated...". You're using `/`, which implies m/d/y, but are passing in d/m/y – Marc B Dec 10 '14 at 14:04

2 Answers2

1

This should work for you:

echo strtotime(str_replace('/', '-',"27/03/2015 23:59:59"));

You have to replace / with -

Rizier123
  • 58,877
  • 16
  • 101
  • 156
1

From the manual: Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed.

So, as Rizier suggests, a possible solution is to replace the slashes with dashes like this:

echo strtotime(str_replace('/', '-',"27/03/2015 23:59:59"));

TecBrat
  • 3,643
  • 3
  • 28
  • 45
  • He did but also the other was copied from the oficial documentation as this one refered – Th3Alchemist Dec 10 '14 at 14:03
  • @TecBrat Now it's okay because you say: "hey if you read the manual here... you will see this..." Now it's a nice reference and answer why OP's code doesn't work! Maybe you can include an answer for OP how to solve this. – Rizier123 Dec 10 '14 at 14:04
  • No matter if it was copied from the manual or from another question, the information is still useful here. – Naomi Dec 10 '14 at 14:04