Posts strtotime in example
Post
Cancel

strtotime in example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//always use http://www.onlineconversion.com/unix_time.htm

echo strtotime(date("Y-m-d")."UTC");
//1487376000 - Sat, 18 Feb 2017 00:00:00 GMT

echo strtotime(date("Y-m-d"));
//1487394000 - Sat, 18 Feb 2017 05:00:00 GMT (takes server time)

echo strtotime(date("Y-m-d")."UTC -2 days");
//1487203200 - Thu, 16 Feb 2017 00:00:00 GMT

//in general knows because or separator character
//http://php.net/manual/en/function.strtotime.php#91165
mm/dd/yyyy - 02/01/2003  - strtotime() returns : 1st February 2003
mm/dd/yy   - 02/01/03    - strtotime() returns : 1st February 2003
yyyy/mm/dd  - 2003/02/01 - strtotime() returns : 1st February 2003
dd-mm-yyyy - 01-02-2003  - strtotime() returns : 1st February 2003
yy-mm-dd   - 03-02-01    - strtotime() returns : 1st February 2003

//MySQL compatible
yyyy-mm-dd - 2003-02-01  - strtotime() returns : 1st February 2003

echo strtotime("02/01/2003UTC");
//1044057600 - Sat, 01 Feb 2003 00:00:00 GMT

echo strtotime("02/01/03");  
//1044075600 - Sat, 01 Feb 2003 05:00:00 GMT (takes server time)

echo strtotime("02/01/03UTC -2 days");
//1043884800 - Thu, 30 Jan 2003 00:00:00 GMT

origin - http://www.pipiscrew.com/?p=6751 strtotime-in-example

This post is licensed under CC BY 4.0 by the author.
Contents

Trending Tags