Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Altering Date returns timestamp

Status
Not open for further replies.

webmigit

Programmer
Aug 3, 2001
2,027
US
I've got this script... if I change the red piece below just to thisNow, I get a date/time string... if I leave it as is, I get a timestamp.

The Parentheses surrounding the value are something I tried just to see if it would change it to a date format, but with or without them I get a timestamp.

Code:
  thisNow = new Date();
  for (i = -5; i < 19; i++) {
    hdate = thisNow.setHours( thisNow.getHours() + i );
    if(i > 0) { posneg = '+'; }
    else if(i < 0) { posneg = '-'; }
    else {posneg = ''; }
    document.getElementById('timeOffset').options[i+5].text = [red](thisNow.setHours(thisNow.getHours() + i))[/red];
  }

Also, can anyone help me, I'd like to remove a lot of the date returned and just say for instance..

Dec 9 08:53 AM
Dec 9 09:53 AM
Dec 9 10:53 AM

All the way around the clock.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Unfortunately javascript has no automatic built in function for date display formatting. However, there are a lot of scripts out there that ppl have written to already do it for you. Here's one that works fine:


-kaht

banghead.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top