0

Why the following two will get same Result??

echo date('d/m/Y',1338156000); will produce output 28/05/2012

And echo date('d/m/Y',1338143400); also produce the same out put 28/05/2012 ??

6
  • 3
    Because those times are 3.5 hours apart - they both reside on the same day. Commented May 30, 2013 at 4:50
  • it gives me the different output 28/05/2012 and 27/05/2012 Commented May 30, 2013 at 4:52
  • 1
    @SumitBijvani could be due to the DST settings Commented May 30, 2013 at 4:54
  • 1338156000 and 1338143400 are seconds. In your case both the seconds lie on the same day. Commented May 30, 2013 at 4:55
  • @ØHankyPankyØ yeah you are right :) Commented May 30, 2013 at 4:56

4 Answers 4

2

Difference of this values is 3.5 hours. So, it is times of one day.

Sign up to request clarification or add additional context in comments.

Comments

2

Quite Simple

<?php 
    echo date('d/m/Y',1338156000); 
    echo "<br />";
    echo date('d/m/Y',1338143400); 
    echo "<br />";

    echo date('d/m/Y H:i:s',1338156000); 
    echo "<br />";
    echo date('d/m/Y H:i:s',1338143400); 
    echo "<br />";


?>

Here, when 27/05/2012 22:00:00 the day is: 27

and when 27/05/2012 18:30:00 the day is: 27

Comments

2

Yes Both will give the same date because time stamp is in seconds.if you print first like

echo date("d/m/y h:i:s", 1338156000);

it will give you result like

28/05/2012 03:30:00

and

echo date('d/m/Y h:i:s',1338143400); 

result is

28/05/2012 12:00:00

for further reference check php date and time manual

Comments

1

As stated by others, its the same date that's why the confusion. But if you simply add time to your own code along with the date your confusion will itself be gone without asking.

<?php
echo date('d/m/Y H:i:s',1338156000);
echo "<br>";
echo date('d/m/Y H:i:s',1338143400);
?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.