Wrox Programmer Forums
|
Visual Studio 2008 For discussing Visual Studio 2008. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Studio 2008 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 23rd, 2010, 06:48 AM
Registered User
 
Join Date: Feb 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Time Format Problem

Hi guys;
I have a major problem with the datetime format.
I'm using a string called _PLC_ClockTime_Value and put it into "ClockTime".
This string can come in in many formats, and I what to specify that format in a Textbox (eg. MM/dd/yy HH:MM:ss) but frankly any format I specify in there I need to format into that format i put into the textbox.

Then it's converted into my format

My code look like this:


string ClockTimeInput = Convert.ToString(_PLC_ClockTime.Value);

DateTime ClockTime = DateTime.Parse(ClockTimeInput);


System.Globalization.DateTimeFormatInfo TimeFormat = new System.Globalization.DateTimeFormatInfo();
TimeFormat.FullDateTimePattern = (PLC_ClockTime_Format.Value.ToString());

DateTime NewTime = Convert.ToDateTime(ClockTime, TimeFormat);
LogInfo(NewTime.ToString("yyyy-MM-dd HH:mm:ss"));
LogInfo(NewTime.ToString());




DateTime SystemTime = DateTime.Now;
TimeSpan ElapsedTime = NewTime.Subtract(SystemTime);
double OffSet = ElapsedTime.TotalMinutes;
_PLC_ClockTimeOffset.Value = OffSet;

Please any help will be greatly valued.

Thankx





Similar Threads
Thread Thread Starter Forum Replies Last Post
Time format problem in userform frankjuel Excel VBA 1 October 10th, 2007 08:34 AM
Time format MDM ASP.NET 2.0 Professional 2 July 12th, 2006 10:37 AM
stored procedure: time format/mismatch problem. MDM ASP.NET 2.0 Professional 1 April 12th, 2006 03:42 PM
Using xs:time to generate time in desired format krayan001 XSLT 0 June 27th, 2005 04:28 PM
Format Date Time ganesh15 PHP How-To 2 August 20th, 2003 05:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.