php time and date

$timestamp=gmmktime(22,50,0,2,10,2015);

It considers Oct 10,2015,22(hour):50(minute):0(second) is the GMT time. It calculates the seconds between this time and GMT Jan 1,1970,0:0:0.

 

$timestamp=mktime(22,50,0,2,10,2015);

It looks for the time zone settings in php.ini: date.timezone=Europe/Berlin. It considers Oct 10,2015,22(hour):50(minute):0(second) is the Berlin time. It calculates the seconds between this time and GMT Jan 1,1970,0:0:0.

 

$timestamp=time();

It reads the digit string of time from your computer(you can also get it by looking at the clock at the right-bottom of your desktop). It looks for the timetone settings of your OS(you can set the timezone in the Control Panel). It considers the digit string is the time representation  in that time zone. It calculates the seconds between this time and GMT Jan 1,1970,0:0:0.

So all the php timestamp functions  calculate the time difference between a time and the GMT   Jan 1,1970,0:0:0.

gmdate("l dS \of F Y h:i:s A");

It gets the current time. It calculates the GMT representation of this time according to the specified time format.

 

date("l dS \of F Y h:i:s A");

It gets the current time(including the digit string and the system time zone). It reads the timezone setting from php.ini. It calculates the representation of this time in that time zone..

 

strftime("%b %d %Y %X", mktime(23,25,0,2,10,2015))

It calculates the time representation for the second parameter(timestamp) according to the timezone specified in php.ini

 

gmstrftime("%b %d %Y %X", mktime(23,25,0,2,10,2015))

It calculates the time representation for the second parameter(timestamp) in GMT. The above two are the different representation  for the same time(timestamp).

Posted in

Leave a Reply