By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,636 Members | 1,213 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,636 IT Pros & Developers. It's quick & easy.

Javascript Max Date

P: 5
Hello

I was wondering if there was a function that I could use that would select the maximum date out of an array of date entries. Could you use the javascript Math.max function and put in a date instead of a number? Just wondering
Aug 4 '08 #1
Share this Question
Share on Google+
8 Replies


hsriat
Expert 100+
P: 1,654
You can use Math.max after converting the date to YYYYMMDD format.
Aug 4 '08 #2

acoder
Expert Mod 15k+
P: 16,027
You could also just use the getTime() method to get a number representation of the Date object.
Aug 4 '08 #3

P: 5
You could also just use the getTime() method to get a number representation of the Date object.
do you think you could give me a sample of what the function would look like?
Aug 4 '08 #4

acoder
Expert Mod 15k+
P: 16,027
Can you show what your array looks like?
Aug 4 '08 #5

P: 5
Can you show what your array looks like?
i dont know what that is
Aug 5 '08 #6

acoder
Expert Mod 15k+
P: 16,027
To quote you from the first post in this thread:
I was wondering if there was a function that I could use that would select the maximum date out of an array of date entries...
That's the array I'm talking about. Is it an array of Date objects or an array of strings representing dates?
Aug 5 '08 #7

P: 5
It is an array of strings representing dates
Aug 5 '08 #8

acoder
Expert Mod 15k+
P: 16,027
So can you give some examples? What format are they in?

You can either use the method suggested by hsriat in post #2, convert the strings into Date objects and use getTime() or just compare them using < or >.
Aug 5 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.