Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Win7 VB.NET
Hi,
I get the date formate like MM-DD-YYYY from DB.
Now this date displays in front end based on Keyboard settings.
Please guide me ...
 
Thanks & Regards,
Anilkumar.M
Posted 14-Oct-12 21:01pm
Edited 14-Oct-12 21:17pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

The System.DateTime.Now property returns a System.DateTime. This is stored in memory in a binary format that most programmers in most circumstances have no need to think about. When you display a DateTime value, or convert it to a string for any other reason, it is converted according to a format string, which can specify any format you like.
 
In this last sense, the answer to your question "if I get DateTime.Now, which Date Time Format is this using?" is "it is not using any DateTime format at all, because you haven't formatted it yet".
 
You specify the format by calling an overload of ToString, or (optionally) if you use System.String.Format. There is a default format, as well, so you don't always have to specify the format.
 
string sysFormat = CultureInfo.CurrentCulture.DateTimeFormat; 
 

and apply the same format on your output data time format, pleaselet me know if you want some thing specific.
 
Thanks,
Ambesha
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 383
1 Richard Deeming 180
2 Yogesh Kumar Tyagi 165
3 ChauhanAjay 156
4 Sergey Alexandrovich Kryukov 151
0 Sergey Alexandrovich Kryukov 6,212
1 OriginalGriff 5,498
2 CPallini 2,473
3 Richard MacCutchan 1,627
4 Abhinav S 1,530


Advertise | Privacy | Mobile
Web03 | 2.8.140814.1 | Last Updated 15 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100