datetime-format

How to convert a DateTime string to a DateTime in SQL Server

社会主义新天地 提交于 2019-12-23 13:21:14
问题 I have a DateTime varchar in this format: 2005-08-08T00:00:00+01:00. Does this format have a name? (it's not ISO8601. Is it RFC3339?) How can I convert it to a DateTime using Transact-Sql? EDIT Here's a summary answer, cobbled together from others input: It is ISO8601 with a time offset from UTC. If it was UTC it would end with a 'Z' instead of '+01:00'. wikipedia You can convert it to local time or to utc as follows: DECLARE @d VARCHAR(25) SET @d = '2007-08-08T00:01:00+01:00' SET @d = '2007

Parsing non-standard date formats with DateTime.TryParseExact

孤者浪人 提交于 2019-12-23 13:16:51
问题 Hi Im trying to parse date strings like "1012012", "1st January 2012". read the Api It says to use d,%d where the date does not have a leading 0. Cant get it working for dates like "1012012" trying to use "d MMM YYYY" for "1st January 2012", what do I use so 'st', 'th' works? using System; using System.IO; using System.Globalization; namespace test { class Script { static public void Main(string [] args) { //String dateString = "9022011"; // q1 String dateString = "9th February 2011"; //q2

JSF 2 Default DateTime Converter Pattern

試著忘記壹切 提交于 2019-12-23 12:53:10
问题 My JSF pages display DateTime from managed beans in this format: "MM/dd/yyyy h:mm a" I want avoid duplicate converter declaration in different pages: <f:convertDateTime type="both" pattern="MM/dd/yyyy h:mm a" dateStyle="short" timeStyle="medium" /> Is there a way to make the above converter default for all DateTime fields? (Experience with JSF 2: 2 months.) 回答1: Just extend the DateTimeConverter class behind <f:convertDateTime> and set the defaults in the constructor. @FacesConverter(

Is getTimezoneOffset() stable during daylight saving transition?

笑着哭i 提交于 2019-12-23 04:31:49
问题 I have date time below conversion logic in Javascript which is converting the UTC time into passed timezone's local time. I am wondering this logic will work fine during Daylight transition? If not what is the remedy for that? I can't use any third party library. I have to use pure javascript or Angular JS. function myTime() { var d1= document.getElementById("txtDate").value; var zOffset = document.getElementById("txtOffset").value; console.log("Date1",d1); var d2 = new Date(d1.replace(/ /g,

Is getTimezoneOffset() stable during daylight saving transition?

夙愿已清 提交于 2019-12-23 04:31:45
问题 I have date time below conversion logic in Javascript which is converting the UTC time into passed timezone's local time. I am wondering this logic will work fine during Daylight transition? If not what is the remedy for that? I can't use any third party library. I have to use pure javascript or Angular JS. function myTime() { var d1= document.getElementById("txtDate").value; var zOffset = document.getElementById("txtOffset").value; console.log("Date1",d1); var d2 = new Date(d1.replace(/ /g,

Rendering hidden form field using @Html.HiddenFor

◇◆丶佛笑我妖孽 提交于 2019-12-23 04:09:27
问题 public class SearchForm { //Note: Property is nullable public DateTime? CurrentViewDate {get;set;} public DateTime StartDate {get;set;} } //In the controller //[GET] public ActionResult Index() { } //[POST] public ActionResult Index(SearchForm formModel) { if(formModel.CurrentViewDate == null) formModel.CurrentViewDate = DateTime.Now.AddDays(1d); else formModel.CurrentViewDate = formModel.CurrentViewDate.AddDays(1d); formModel.StartDate = DateTime.Now; } //In view @Html.HiddenFor(c => c

Rendering hidden form field using @Html.HiddenFor

时光怂恿深爱的人放手 提交于 2019-12-23 04:09:10
问题 public class SearchForm { //Note: Property is nullable public DateTime? CurrentViewDate {get;set;} public DateTime StartDate {get;set;} } //In the controller //[GET] public ActionResult Index() { } //[POST] public ActionResult Index(SearchForm formModel) { if(formModel.CurrentViewDate == null) formModel.CurrentViewDate = DateTime.Now.AddDays(1d); else formModel.CurrentViewDate = formModel.CurrentViewDate.AddDays(1d); formModel.StartDate = DateTime.Now; } //In view @Html.HiddenFor(c => c

DateTime format in c# [duplicate]

怎甘沉沦 提交于 2019-12-23 03:32:23
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Format date in C# I want to display the date in the format May 16, 2011 . I have used format String.Format("{0:D}" by which i got the output like Monday, May 16, 2011 . So please any one tell me how i will be able to show date time in the following format May 16, 2011 Thanks in advance 回答1: "{0:MMMM d, yyyy}" Here is the documentation. Custom Date and Time Format Strings 回答2: DateTime dt = DateTime.Now; String

Qt seconds to DD HH SS

拜拜、爱过 提交于 2019-12-22 20:00:11
问题 using Qt 4.8 how can I print the time in the format DD HH SS? I have the seconds and I want to get back a string in that format. 回答1: QDateTime::fromTime_t(seconds).toString("ss hh DD"); see http://qt-project.org/doc/qt-5.0/qdatetime.html#toString If you want a duration ( your question was really unclear) try something like : QString seconds_to_DHMS(quint32 duration) { QString res; int seconds = (int) (duration % 60); duration /= 60; int minutes = (int) (duration % 60); duration /= 60; int

Is DateTime.parse() in Ruby dependent on locale?

旧时模样 提交于 2019-12-22 18:02:19
问题 I'm wondering regarding the output of the following example: when parsing 01/03 , will it be resolved as Mar, 1st or Jan, 3rd ? 回答1: Ruby is not locale dependent. Because Ruby is a server-side language and not a client-side language like JavaScript, Ruby uses the system clock from your web app server - and uses this information to calculate the time. Whatever timezone you have your system set to is what your Ruby app will use. When parsing a date from a string, DateTime will make its best