datetime-format

Parse CIM_DateTime to .Net DateTime

你说的曾经没有我的故事 提交于 2019-11-29 14:12:06
My application is receiving some date information from WMI. This in the form of strings with the following format: yyyymmddHHMMSS.mmmmmmsUUU For more details on this format, see here . I'm interested in parsing everything before the period. I have the following code: string testDate = "20010701212212"; // July, 01, 2001 21:22:12, in the format specified above string format = "yyyyMMddHHmmSS"; CultureInfo culture = CultureInfo.InvariantCulture; DateTime newDate = DateTime.ParseExact(date, format, culture); This always fails on the call to ParseExact(), with an exception stating that "String was

Datetime format from iPhone settings and GMT offset

六眼飞鱼酱① 提交于 2019-11-29 13:15:16
I have string with date time format e.g.: 2013-05-28 10:56:31 How can I format this string to the iPhone default format? (in iPhone settings) And how to set datetime in GMT plus time shift offset (set in iphone too). e.g. GMT+1 Is this possible? You can use NSDateFormatter to achieve this. NSString *dateString = @"2013-05-28 10:56:31"; NSDateFormatter *formatter = [[NSDateFormatter alloc]init]; //Special Locale for fixed dateStrings NSLocale *locale = [[NSLocale alloc]initWithLocaleIdentifier:@"en_US_POSIX"]; [formatter setLocale:locale]; //Assuming the dateString is in GMT+00:00 //formatter

Convert a string with 'YYYYMMDDHHMMSS' format to datetime

谁说胖子不能爱 提交于 2019-11-29 12:28:20
问题 I recognize there has been many questions posted about converting strings to datetime already but I haven't found anything for converting a string like 20120225143620 which includes seconds. I was trying to perform a clean conversion without substring-ing each segment out and concatenating with / and : . Does anyone have any suggestions? 回答1: You can use the STUFF() method to insert characters into your string to format it in to a value SQL Server will be able to understand: DECLARE

Date conversion from C# to MySql Format

柔情痞子 提交于 2019-11-29 12:04:29
How to convert C# datetime to MySql Datetime format. I am getting value from text box like 7/27/2011 this format. But i want to convert in this format 2011-7-27. So here i am stuking. Please help me. My objective is to filter the record between two dates and show in a listview control in asp.net. Here is my code: DateTime dt1 = Convert.ToDateTime(txtToDate.Text); DateTime dt2 = Convert.ToDateTime(txtFromDate.Text); lvAlert.DataSource = facade.GetAlertsByDate(dt1, dt2); lvAlert.DataBind(); I haven't used MySQL with .NET, but Oracle has similar date conversion issues with .NET. The only way to

Filter by datetime MYSQL formatting

孤者浪人 提交于 2019-11-29 11:44:57
问题 I have a Mysql Table that is used for a log file on the that table there is a field called 'log_date' And it stores the date in the following format( %Y-%m-%d %H:%i.%s ).On the DB the dates look like something this 2013-20-05 00:00.00. Lets say today's date is 2013-20-05 And I have log files from 2013-01-01 to present day. If I run a query like this: SELECT * FROM log_table WHERE STR_TO_DATE(log_date, '%Y-%m-%d %H:%i.%s') < '2013-05-05 00:00.00' This is returning every row in the DB including

Convert Date time to specific format in C#

可紊 提交于 2019-11-29 10:24:23
问题 I want to convert date time to specify format that is Wed Aug 01 2012 14:37:50 GMT+0530 (India Standard Time) Actually i want to display the Timer using Jquery on web page. So i have tried some format i knew. And found some from http://www.dotnetperls.com/datetime-format But none of them return the result what i require. Actually i have to pass the time from server So i have tried the following code. Code Behind protected void Button3_Click(object sender, EventArgs e) { //string hello =

Datetime format issue in IIS 7 server

我的未来我决定 提交于 2019-11-29 09:57:54
问题 I have hosted one of my site on IIS 7, WS2008. Later i have realize there is some datetime format issue, like me expecting things in dd/MM/yyyy format but it was in MM/dd/yyyy format and because of this it used to give me datetime conversion error. So i have changed the datetime format by following step: Control Panel -> Regional and Language Options -> Advanced and changed registry entry regedit >> HKEY_USERS>>DEFAULT>>Control Panel>>International and here we have changed "sLongDate" and

Get just the hour of day from DateTime using either 12 or 24 hour format as defined by the current culture

南楼画角 提交于 2019-11-29 09:37:36
.Net has the built in ToShortTimeString() function for DateTime that uses the CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern format. It returns something like this for en-US: "5:00 pm". For a 24 hour culture such as de-DE it would return "17:00". What I want is a way to just return just the hour (So "5 pm" and "17" in the cases above) that works with every culture. What's the best/cleanest way to do this? Thanks! // displays "15" because my current culture is en-GB Console.WriteLine(DateTime.Now.ToHourString()); // displays "3 pm" Console.WriteLine(DateTime.Now.ToHourString(new

not being able to convert from FILETIME (windows time) to dateTime ( I get a different date )

吃可爱长大的小学妹 提交于 2019-11-29 09:29:59
问题 Most of the files I read get the right time when using the following method to convert: // works great most of the time private static DateTime convertToDateTime(System.Runtime.InteropServices.ComTypes.FILETIME time) { long highBits = time.dwHighDateTime; highBits = highBits << 32; return DateTime.FromFileTimeUtc(highBits + time.dwLowDateTime); } Here I have an example in visual studio to show how this method sometimes does not work for example I will show the actual file in my computer and

How to convert the integer date format into YYYYMMDD?

回眸只為那壹抹淺笑 提交于 2019-11-29 09:16:54
Python and Matlab quite often have integer date representations as follows: 733828.0 733829.0 733832.0 733833.0 733834.0 733835.0 733836.0 733839.0 733840.0 733841.0 these numbers correspond to some dates this year. Do you guys know which function can convert them back to YYYYMMDD format? thanks a million! The datetime.datetime class can help you here. The following works, if those values are treated as integer days (you don't specify what they are). >>> from datetime import datetime >>> dt = datetime.fromordinal(733828) >>> dt datetime.datetime(2010, 2, 25, 0, 0) >>> dt.strftime('%Y%m%d')