Date And Time Format issue in asp.net C#

Posted on 2013-09-27
Medium Priority
Last Modified: 2013-10-23
How to initialize following format to date time variable?
i.e. 2013-09-29T10:21:25.078Z
My Result must be as follows :
DateTime dateTime = new DateTime();
dateTime =  2013-09-29T10:21:25.078Z
Please help me on this.
Question by:iipl
LVL 52

Expert Comment

by:Carl Tawn
ID: 39527824
You should be able to use the DateTime types Parse() method:
DateTime dt = DateTime.Parse("2013-09-29T10:21:25.078Z");

Open in new window

LVL 19

Expert Comment

by:Ken Butters
ID: 39527901
Try this:

DateTime dateTime = DateTime.Parse("2013-09-29T10:21:25.078Z");
LVL 19

Expert Comment

by:Ken Butters
ID: 39527908
whoops... carl_tawn beat me to it.
Managing Security & Risk at the Speed of Business

Gartner Research VP, Neil McDonald & AlgoSec CTO, Prof. Avishai Wool, discuss the business-driven approach to automated security policy management, its benefits and how to align security policy management with business processes to address today's security challenges.


Author Comment

ID: 39529593
Thanks for your valuable suggestion.
I have tried your solution but it should be return 29/09/2013 15:51:25.
But i need following format in C# and assign to DateTime variable.


Expert Comment

ID: 39531829
Have a go with this.

DateTime dt= new DateTime();
String.Format("{0:MM/dd/yyyy}", dt)

Happy coding.

Accepted Solution

iipl earned 0 total points
ID: 39582071
Thanks to all for participation.

Actually the problem was due to DateTimeKind property. Once set to appropriate for UTF, the vendor API had accepted the value automatically.


Author Closing Comment

ID: 39593480
The question was posted in a bit hurry so could not include entire scenario or the problem. Now the problem was due to DateTimeKind property of DateTime object and was lately resolved by using appropriate value.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
Apart from its culture, demographics, and beliefs, Indian infrastructure is also quite complex, especially because of the challenge of overpopulation that stares us right in the eye. Due to this, it has been quite difficult to anticipate the traffi…
Watch the video to know how one can repair corrupt Exchange OST file effortlessly and convert OST emails to MS Outlook PST file format by using Kernel for OST to PST converter tool. It can convert OST to MSG, MBOX, EML to access them. It can migrate…
To export Lotus Notes to Outlook PST or Exchange and Domino Server files to Exchange Server or PST files with ease, go for Kernel for Lotus Notes to Outlook conversion tool. Through the video, you can watch the conversion process. A common user with…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question