I have a date in this format dd/m/yyyy (if the month is less than 10) that i want to convert to this one dd/mm/yyyy no matter what is the value of the month.
thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here’s a simple solution if you know the string is in the exact format you’ve posted:
Of course, you may want to check for
d/m/yyyy, ord/mm/yyyy.Another option, in that case, is:
Again, assuming the date is the whole string, and not partial in it. The pattern reads:
\b\d\b– A digit that is a whole word (wrapped by non-alphanumeric characters or the edge of the string)/g– Global replace, as we may have two matches.0$&– Add a zero to the whole match.