Add the php code for the calendar in the blog. Do you want to add a calendar to your blog by adding the php code for adding a calendar? Blue1000 is here to share with you a simple PHP blog calendar implementation code. if you need it, refer to the php code for adding a calendar in a blog.
Do you want to add a calendar in your blog? Blue1000 is here to share with you a simple PHP blog calendar implementation code. if you need it, please refer to it. it is very easy to query the database, you just need to modify the field name to be the same as your database.
The code is as follows:
Function calendarnew ($ starttime = 0 ){
Global $ db, $ tablepre, $ timestamp, $ site_timeoffset, $ site_dateformat, $ curtime;
$ Starttime = $ starttime? $ Starttime: $ timestamp;
$ Curtime = gmdate ($ site_dateformat, $ starttime + $ timeoffset * 3600 );
$ Pendtime = $ starttime-(gmdate ('J', $ starttime + $ timeoffset * 3600)-1) * 86400-($ starttime + $ timeoffset * 3600) % 86400;
$ Pstarttime = $ pendtime-gmdate ('t', $ pendtime + $ timeoffset * 3600-1) * 86400;
$ Nstarttime = $ pendtime + gmdate ('t', $ pendtime + $ timeoffset * 3600 + 1) * 86400;
$ Nendtime = $ nstarttime + gmdate ('t', $ nstarttime + $ timeoffset * 3600 + 1) * 86400;
List ($ skip, $ dim) = explode ('-', gmdate ('W-t', $ pendtime + $ timeoffset * 3600 + 1 ));
$ Rows = ceil ($ skip + $ dim)/7 );
$ Blogs = array ();
$ Query = $ db-> query ("SELECT dateline FROM {$ tablepre} vitaitems WHERE dateline BETWEEN '$ pendtime' AND '$ nstarttime '");
While ($ blog = $ db-> fetch_array ($ query )){
$ Day = gmdate ('J', $ blog ['Dateline '] + $ timeoffset X 3600 );
! Isset ($ blogs [$ day])? $ Blogs [$ day] = array ('num' => 1, 'Dateline '=> $ blog ['Dateline']-$ blog ['Dateline '] % 86400 ): $ blogs [$ day] ['num'] ++;
}
$ Cal = '';
For ($ row = 0; $ row <$ rows; $ row ++ ){
$ Cal. = '';
For ($ col = 0; $ col <7; $ col ++ ){
$ Cur = $ row * 7 + $ col-$ skip + 1;
$ Curtd = $ row * 7 + $ col <$ skip | $ cur> $ dim? '': $ Cur;
If (! Isset ($ blogs [$ cur]) {
$ Cal. = ''. $ curtd .'';
} Else {
$ Cal. = ''. $ cur .'';
}
}
$ Cal. = '';
}
Return $ cal;
}
Do you want to add a calendar in your blog? Blue1000 is here to share with you a simple PHP blog calendar implementation code. if you need it, please refer to I...