Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Geting a date from Calendar Control
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01141604
Message ID:
01141645
Vues:
9
Hi Gerard,

Er, it's a really bad idea to parse date values like this because date strings may vary depending on locale. If somebody in a different country runs your application your date string may be turned around and you'll get completely mangled values.

The thing to do if you want to format dates is to use ToString() with format values:
DateTime.Now.ToString("yy-MM-dd")
for example.

Look under DateTimeInfo in the MSDN docs for the format patterns available.

+++ Rick ---




>I have a calendar control and a text box on a Web form, but the ist character is being dropped from the date (if the day has 2 digits)
>
>protected void Calendar1_SelectionChanged(object sender, EventArgs e)
> {
> txtDate1.Text = Calendar1.SelectedDate.Date.ToString().Substring(1,10);
> }
>If date is 9/07/2006 ok , but for 28/07/2006 it moves 8/07/2006
>I've tried increasing the Sibstring to (1,11) but it starts movng the time bit.
>
>Any help appreciated
>
>Regards,
>Gerard
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform