I have a WordPress blog where I need to display an image on each post only for 3 weeks. This means that after 3 weeks have passed, since each post was published, the image will disappear.
First, I made sure that the image appears each time a new post is published. This was easy. Then I needed to get the date when each posts was published and I used
The problem I'm having right now is that I don't know how to use
the_time(); function to do anything (compare it with current time, adding 3 weeks etc).
now = new Date(); threeweeksfromnow = new Date(now.getTime() + (21 * 24 * 60 * 60 * 1000)); months = new Array("January ","February ","March ","April ","May ","June ","July ","August ","September ","October ","November ","December "); document.write("Today's date is: " + months[now.getMonth()] + now.getDate() + "<br>"); document.write("Three weeks from today is: " + months[threeweeksfromnow.getMonth()] + threeweeksfromnow.getDate() + "<br>");
I tried to tie this code to
the_time(); function in wordpress but it didn't worked. Does anyone have any idea how I might solve this problem?