My goal is to adjust the hour on the string and if there is noway to get the hour to edit, can anyone help me using string functions that somehow pinpoint the hour location so I can come up with a way to replace the hour with more desirable one.
var myDate = new Date("Fri May 11 13:36:48 PDT 2009");
var dayOfWeek = day[myDate.getDay()];
var monthName = month[myDate.getMonth()];
var year = parseInt(myDate.getYear()) + 1900;
var dateDate = myDate.getDate();
var hour = myDate.getHours();
var min = myDate.getMinutes();
var sec = myDate.getSeconds();
var timeOfDay = "AM";
if (parseInt(hour) > 12) {
hour = parseInt(hour) - 12;
timeOfDay = "PM";
}
TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
^ in the "year" the + 1900 is for FF, as it getYear returns a number equal the the number of years since 1900.
For IE you don't need it, so you'll need to build in a browser check...unless someone else has a better way to grab the year.
TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.