Why always get the wrong formatting although I’ve set it?
I think the code is right but does not get the right result.
I have:
Private Now_Date As String = Date.Parse(DateTime.Now.ToString("dd/MM/yyyy"))
For today, it should return: 12/05/2012, right? But I always get: 12/5/2012. This is also for: 09/05/2012, and I will get: 9/5/2012. How I can do that? Thanks.
Try
You were turning it from a DateTime, to a String, back to DateTime, then back to String.
You should also get into the habit of using
Option Explicit OnandOption Strict Onin your code. It would have told you that you were trying to save aDateTimeas aString, which would have given you a clue. Your code would have produced the error: