Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using date in a text Box and it is coming from response in the format of dd/mm/yyyy, so how can I change it into dd-mm-yyyy format. Any idea??
Posted

I'm not exactly sure how you get your date, in case it is just a string then use DamithSL suggestion.
In case it is a DateTime structure then just use the following:
VB
Dim dateSample = DateTime.Now
Dim dateText = dateSample.ToString("dd-MM-yyyy", CultureInfo.InvariantCulture)
 
Share this answer
 
if it is string then you can simply replace the / with -

VB
input = input.Replace("/", "-")
 
Share this answer
 
Try this code:

VB
Dim Currentdate = DateTime.Now
Dim dateText = Currentdate.ToString("dd-MM-yyyy", CultureInfo.InvariantCulture)


Ref:
1) CultureInfo.InvariantCulture Property
2) What does CultureInfo.InvariantCulture mean
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900