Problem:
You have a date. You want to convert it to its equivalent Unix timestamp.
Solution:
You can find Unix timestamp of a date in the following two ways-
Method 1: using strtotime() function
If you provide a date or any English textual datetime description as parameter in the strtotime() function, it will return Unix timestamp of the date. See the following example-
<?php echo $timestamp = strtotime("2014-05-10"); ?>
Output:
1399672800
Note: When using ‘/’ as separator, then American m/d/y date format is assumed. On the other hand, if dash or dot is used as separator, then European d-m-y or d.m.y date format is used. So, follow the conventions. To avoid any confusion, you can use YYYY-mm-dd format which I used in the both examples in this page.
Method 2: Using mktime() function
mktime() function can tell you the unix timestamp for a date. See the following example. It will return the timestamp of 10th May 2014.
<?php echo mktime(0, 0, 0, 05, 10, 2014); ?>
Output:
1399672800