I have updated the online demo.
Instead of doing the math via the script, I now have it keep track of the milliseconds and the just format that. It'll just add x amount of milliseconds to the current milliseconds and then formats the field.
I also modified the default getRawValue() function. The new getRawValue() will return the milliseconds while the getValue() will return the same formatted time that you see in the field.
Let me know if you like this better. The root post has the updated attachment and the online demo has been updated.
Well, I tested only the demo online and it looks very nice :)
But is possible to get the minutes, hours, everything you want?
You mean have like a separate function to return just the hours or just the minutes to whatever is being shown? That would be an easy addition if that's what you'd want!
Yeah, that's it!
Sometimes you just want to know the hour, if it's am or pm and things like that :)
Check out the online demo! Add a few buttons for ya! Also updated the zip file at the root post.
Anything else ya think of?
Cleaned up some code. Instead of doing all the formatting by hand, I'm using the date.format() function now. Can't believe I didn't think of that earlier so now it's a lot better! 1 line of code instead of about 30!
The 24 hour one does not change at all. It just flickers.
In fact what it is doing is switching from am to pm on every repeat of the click event.
Just tested with IE, FF, and Chrome on Win and it changes up and down as expected so can you tell me what your using so I can see what you're seeing?
Originally Posted by Animal
What I have the script to do, and it using the same function for both types just formats it differently, is I get where the cursor is so that I can tell which time to get (hour, minute, second or am/pm), I add x amount of milliseconds to the current milliseconds that is held in a config option, create a new date object and then format it.
Originally Posted by Animal
I'm not doing any of the math or formatting by hand anymore. Pretty much letting the date function take care of that. Only math is to add x amount of milliseconds. So I'm not sure why it would be switching from am to pm on every click event because it should just be adding milliseconds and then formatting the new date object.
A lot of updates, congratulations!
I've tested here, without problems.
I don't know anything more you can do it....hehe
You could do a function that we pass an hour and it returns the difference of the hour we passed and the hour of the component.....
I just made some changes. I have dropped the following functions: getHours(), getMinutes(), and getSeconds(). The reason for this is that I have modified the getValue() function. U can pass a date string that will format the time to whatever u need. This can return just the hours, for example, or u can mix and match some.
Couple of examples:
To get just the hours u can do this
To get the minutes u can do this
To get seconds since. EPOCH
If u check the online demo, I have provided the descriptions and what it would return.
I have decided to leave the isAM() and isPM() functions.
Let me know if u like this change, it provides flexibility.