An example of conversion between a PHP timestamp and a date. 1. in php, the time conversion function strtotime ("today") date (Y-m-dH: I, $ unixtime) 2. to obtain the unix timestamp of today in php, you can use $ todaytimestrtot
1. time conversion function in php
Strtotime ("today ")
Date ("Y-m-d H: I", $ unixtime)
2. obtain the timestamp of today's in php.
To obtain the unix timestamp at zero point, you can use $ todaytime = strtotime ("today "),
Then use date ("Y-m-d H: I", $ todaytime) to convert to date.
3. in php, the timestamp is converted to a date and different content is displayed according to the time, such as just, minutes ago, hours ago, today, yesterday, etc.
/* Time conversion function */
Function transTime ($ ustime ){
$ Ytime = date ("Y-m-d H: I", $ ustime );
$ Rtime = date ("n month j day H: I", $ ustime );
$ Htime = date ("H: I", $ ustime );
$ Time = time ()-$ ustime;
$ Todaytime = strtotime ("today ");
$ Time1 = time ()-$ todaytime;
If ($ time <60 ){
$ Str = 'gang ';
} Else if ($ time <60*60 ){
$ Min = floor ($ time/60 );
$ Str = $ min. 'minute ago ';
} Else if ($ time <$ time1 ){
$ Str = 'Today '. $ htime;
} Else {
$ Str = $ rtime;
}
Return $ str;
}
In this function, you can add more comparisons to make the displayed date more specific. for example, you can add more specific dates before the second or the day before yesterday.
4. fill 0 in php date and do not fill 0
Echo date ('Y-m-D'); display
Echo date ('Y-n-J'); display
Strtotime ("today") date ("Y-m-d H: I", $ unixtime) 2. in php, to obtain the unix timestamp of today's zero point, you can use $ todaytime = strtot...