fork download
  1. <?php
  2. date_default_timezone_set("Asia/Kolkata");
  3. echo $time = strtotime("01-Feb-2013 00:00:00")."\n";
  4. echo $tm = @date("d-M-Y", $time);
  5. $latest = new DateTime($tm);
  6. //$now = time();
  7. $time = strtotime("01-Jan-2013");
  8. $tm = date("d-M-Y", $time);
  9. $now = new DateTime($tm);
  10. print_r ($now);
  11. $diff = $now->diff($latest);
  12. echo $diff->format(' %y years %m months %d days');
  13. $pre = new DateTime("01-Jan-2013");
  14. $diff = $pre->diff($latest);
  15. echo $diff->format(" %d days, %m months, %y years");
  16.  
  17. echo "\n";
  18.  
  19. echo $time = strtotime("28-Feb-2013 23:59:59")."\n";
  20. echo $tm = @date("d-M-Y", $time)."\n";
  21.  
  22. echo $time = strtotime("31-Mar-2013 23:59:59")."\n";
  23. echo $tm = @date("d-M-Y", $time)."\n";
  24.  
  25. echo $tm = @date("M", strtotime("31-Mar-2013"));
  26. echo (string)$tm;
  27. if($tm == 'Mar'){
  28. echo "March";
  29. }
  30.  
  31. echo "\n\n\n\n";
  32. echo $time = strtotime("01-Jan-2013 00:00:00");
  33. echo "\n";
  34. echo $tm = date("d-M-Y h:i:s a", $time);
  35. echo "\n";
  36. echo $time = strtotime("01-Feb-2013 00:00:00");
  37. echo "\n";
  38. echo $tm = date("d-M-Y h:i:s a", $time);
  39. echo "\n";
  40. echo $time = strtotime("01-Mar-2013 00:00:00");
  41. echo "\n";
  42. echo $tm = date("d-M-Y h:i:s a", $time);
  43.  
  44. echo "\n";echo "\n";
  45. $a = new DateTime(date("d-M-Y", strtotime("30-Jan-2013")));
  46. $b = new DateTime(date("d-M-Y", strtotime("31-Jan-2013 23:59:59")));
  47. $diff = $a->diff($b);
  48. echo $diff->days;
  49. echo "\n";echo "\n";
  50.  
  51. echo date("d-M-Y", strtotime("+30 days", strtotime("25-Jan-2013")));
  52.  
  53. echo "\n";
  54.  
  55. echo $time = strtotime("1-Apr-2013 00:00:00");
  56. echo " => ";
  57. echo date("d-M-Y", $time);
  58. echo "\n";
  59. echo $time = strtotime("1-Apr-2013 23:59:59");
  60. echo " => ";
  61. echo date("d-M-Y H:i:s", $time);
  62. echo "\n";
  63. echo $time = strtotime("1-May-2013 00:00:00");
  64. echo " => ";
  65. echo date("d-M-Y", $time);
  66. echo "\n";
  67. echo $time = strtotime("1-May-2013 23:59:59");
  68. echo " => ";
  69. echo date("d-M-Y H:i:s", $time);
  70. echo "\n";
  71. echo $time = strtotime("1-Jun-2013 00:00:00");
  72. echo " => ";
  73. echo date("d-M-Y", $time);
  74. echo "\n";
  75. echo $time = strtotime("1-Jun-2013 23:59:59");
  76. echo " => ";
  77. echo date("d-M-Y H:i:s", $time);
  78. echo "\n";
  79. ?>
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
1359657000
01-Feb-2013DateTime Object
(
    [date] => 2013-01-01 00:00:00
    [timezone_type] => 3
    [timezone] => Asia/Kolkata
)
   0 years 1 months 0 days  0 days, 1 months, 0 years
1362076199
28-Feb-2013
1364754599
31-Mar-2013
MarMarMarch



1356978600
01-Jan-2013 12:00:00 am
1359657000
01-Feb-2013 12:00:00 am
1362076200
01-Mar-2013 12:00:00 am

1

24-Feb-2013
1364754600 => 01-Apr-2013
1364840999 => 01-Apr-2013 23:59:59
1367346600 => 01-May-2013
1367432999 => 01-May-2013 23:59:59
1370025000 => 01-Jun-2013
1370111399 => 01-Jun-2013 23:59:59