In Client Script, how can I compare 2 dates(with time) that are in different format.

JLeong
Mega Sage

In Client Script, how can I compare 2 dates(with time) that are in different format.

ex   yyyy-mm-dd HH:mm:ss and MM-dd-yyyy hh:mm:ss (12 hours)

Somehow I need to convert the 2nd date&time to system format and then compare to the first date. But I do not know how. Please assist.

1 ACCEPTED SOLUTION

Using "getDisplayValue()" will retrieve the date/time in the person's timezone and display format.   So you could use that on both date variables to force them into the same timezone.



gdate.getDisplayValue()


View solution in original post

13 REPLIES 13

Jim Coyne
Kilo Patron

Check out john.roberts's post about comparing dates in client scripts - Comparing Client Dates



The compareDates function takes in the format for both dates as parameters so you should not have to convert them first.


Did that answer your question?   If so, can you mark the response as the Correct Answer so other users know this was a valid solution.   Thanks.


Thanks Jim for the link. It helped however, the numeric value of the dates are not the same because of the different timezone.




OK, so not only different formats, but you have different timezones to deal with as well?