Need a new web host or having a problem with a script? Tips and advice on the best way to design, build and maintain your most valuable asset - your website!

html code to display last month on page

simoni
 
Posts: 6
Joined: 23 Nov 08
Location: New Zealand

html code to display last month on page

Hi there,

I am trying to find a html code which allows me to have the month and year displayed for the previous month.

i.e. Actual month = August 2009
displayed month = July 2009

Actual Month January 2010
Displayed month = December 2009

Is it possible to do it with HTML?
Are there any wordpress plugins which would do this?

Look forward to your answers.....

Thanks

Simon
 

www.beyondfirstclass.co.nz - Providing Exceptional Consultancy Services for Exceptional People
 
Moderator
wollowra
 
Posts: 1268
Joined: 14 Mar 08
Location: Australia

ok, I can not vouch for any of these so make surew you scan the file etc...
I take no responsibility...lol
I just searched on google.
You may also want to ask someone on the wordpress forums.

http://www.sourcecodeonline.com/details ... in_c_.html

or

http://software.informer.com/getfree-ht ... cker-code/

Regards
Troy
 


Enjoy the little things, for one day you may look back and realize
they were the big things.

-- Robert Brault
 
PremiumMember
gradyp
 
Posts: 921
Joined: 28 Jun 09
Location: United States

Simon,

I don't think there's a way to do it with "standardized" HTML (ie code that should work across all browsers and platforms). Proper HTML should only mark up the code. It may be possible with a script of some kind, though where you would find one, I don't know offhand. If you can't find it with a plug-in, you might search for a script.

Grady
 

Want to learn how to start achieving your goals in life and for your sites? Check out some lessons I've learned from Emmitt Smith's book, Game On! http://www.successbuildingblocks.com/how-to-start-achieving-your-goals-in-life
 
Site Admin
paulus
 
Posts: 26
Joined: 06 Apr 08
Location: New Zealand

Hi Simon,
to do what your asking you'll be needing to use JavaScript - you can copy and paste the script I've supplied below to do what your after. This will work in pretty much all cases except when a user has JavaScript disabled in their browser.

Just paste this into the the top of your page somewhere.
Code: Select all
<script type="text/javascript">
   var myDate = new Date();
   var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
   var m = myDate.getMonth();
   var year = myDate.getYear() + 1900;
   if(m == 0){
      m = 11;
      year = year - 1;
   }else{
      m--;
   }
   var month = months[m];
</script>


And then paste this anywhere in the page you want to display the date
Code: Select all
<script type="text/javascript">document.write(month + ' ' + year);</script>


If you have any trouble or any questions, just post them and I'll get back to you asap.
 

<--websta*-->

http://www.affilorama.com
 
Moderator
wollowra
 
Posts: 1268
Joined: 14 Mar 08
Location: Australia

Just out of interest Simon,
What do you need this for?

Regards
Troy
 


Enjoy the little things, for one day you may look back and realize
they were the big things.

-- Robert Brault