1

When I use this function in excel

=MOD("06/03/1992";7)

it returns 6

How to make the function in PHP? I try this code in PHP, but the result is different

$today = strtotime("06-03-1992");
$mod = ($today/86400) % 7;
echo $mod;
//return 0

Thanks

SnakeEye
  • 61
  • 7

1 Answers1

1

The problem is you calculate with 2 different numbers:

  1. Excel converts "1992-06-03" internally into 33'758.
  2. strtotime returns the UNIX timestamp in seconds; dividing it [as you did] by 86'400 returns 8'188.

As you can see the values don't match.

I refer to this post which describes how to convert an Excel Date to Unix timestamp. This should fix your problem.

Community
  • 1
  • 1
Peter VARGA
  • 4,780
  • 3
  • 39
  • 75
  • [link](http://fczaja.blogspot.co.id/2011/06/convert-excel-date-into-timestamp.html) – An'im Fahmy Oct 22 '16 at 05:25
  • [fczaja](http://fczaja.blogspot.co.id/2011/06/convert-excel-date-into-timestamp.html) What is $excelDate format in that article? Thanks, sorry for comment before – An'im Fahmy Oct 22 '16 at 05:26