datetime

Time stamp parsing from the beginning of a string in C#

Hi all, I am working on re-writing an existing Java software solution in .NET. At one point, the Java solution reads a time stamp at the beginning of a string, simply like this: SimpleDateFormat dateFormat = new SimpleDateFormat(timeFormat); dateFormat.setLenient(false); try { timeStamp = dateFormat.parse(line); } catch (ParseExce...

Best way to get maximum Date value in java?

I'm writing a bit of logic that requires treating null dates as meaning forever in the future (the date in question is an expiration date, which may or may not exist). Instead of putting in special cases for a null date throughout the code, I want to just convert null into the maximum possible Date. I don't see any obvious ways to get su...

How does .Net process get the Culture information

I have a windows service running (C#, .Net 2.0) on Windows 2003 R2. In one server the System.Threading.Thread.CurrentThread.CurrentCulture is {en-AU} and in the other {en-US}. This has caused a difference when calling ToString() on a datetime object. I want the Culture to be {en-AU}. I checked the "Regional and Language Setting". In bot...

Weird Time Issue in Python

Problem with using times in Python. Terminal > Python >>> calendar.timegm(datetime.datetime.now().utctimetuple()) 1258449380 This time indicates GMT: Tue, 17 Nov 2009 09:16:20 GMT Eclipse via Django Server >>> calendar.timegm(datetime.datetime.now().utctimetuple()) 1258427784 This time indicates GMT: Tue, 17 Nov 2009 03:16:24 GMT...

How to convert a date String into the right format in Java?

Can somebody please explain to me how I can convert 2009-10-27 14:36:59.580250 into 27.10.2009, 14:36 ? The first date is available as a string and the second one should be a string as well ;) Up to now I'm not so into date conversion within Java... Thanks in advance! ...

No datetime values populated from MySQL using SubSonic 3 Linq

I have a MySQL table with a couple of Datetime columns. The columns are set to allow null and some have default value '0000-00-00 00:00:00'. This is a conversion project from ASP to ASP.NET so the table is full of data, and where some rows still have the default value, so I had to set "Allow Zero Datetime=True" in the connectionstring to...

How to use Python to calculate time

I want to write python script that acts as a time calculator. For example: Suppose the time is now 13:05:00 I want to add 1 hour, 23 minutes, and 10 seconds to it. and I want to print the answer out. How do I do this in Python? What if date is also involved? ...

PHP 5.3 DateTime for recurring events

I have a calendar application which utilizes the newer PHP DateTime classes. I have a way that I handle recurring events, but it seems hack-ish and I wanted to see if you guys have better ideas: I have a recurring event that starts 11/16/2009 (Nov 16, 2009) It will occur every 3 days The event will recur indefinitely Let's say the us...

Validate date textbox

I'm using the following code to check if a valid date has been typed into a textbox: public bool ValidateDate(Control ctrl) { if (!string.IsNullOrEmpty(ctrl.Text)) { DateTime value; if (!DateTime.TryParse(ctrl.Text, out value)) { return false; } } return true; } private void ...

Get Intervals Between Two Times

A User will specify a time interval of n secs/mins/hours and then two times (start / stop). I need to be able to take this interval, and then step through the start and stop times, in order to get a list of these times. Then after this, I will perform a database look up via a table.objects.filter, in order to retrieve the data correspon...

Why can't DateTime.Parse parse UTC date

Why can't it parse this: DateTime.Parse("Tue, 1 Jan 2008 00:00:00 UTC") ...

Datetime picker below div

Can anyone help me discover why my datetime picker is hiding behind the rest of the divs? http://www.lcslegal.co.uk/booking-form.html I have added this line of css to try and fix it in custom.css but to no avail: .ui-datepicker, #ui-timepicker-div { z-index:1003; } ...

Why does SQL Server 2005 miss a within range DATETIME value

Can anybody tell me why my Database selection queries asking for an orderid WHERE [order].dateplaced >= DATEADD(millisecond,-3,ISNULL(@datefrom, @searchscope)) AND [order].dateplaced < DATEADD(millisecond,-3,DATEADD(day,1,ISNULL(@dateto, GETDATE()))) Is missing out an order over three and a half minutes before midnight on the @date...

How can I account for "AM" or "PM" with datetime.strptime?

Specifically I have code that simplifies to this: from datetime import datetime date_string = '2009-11-29 03:17 PM' format = '%Y-%m-%d %H:%M %p' my_date = datetime.strptime(date_string, format) # This prints '2009-11-29 03:17 AM' print my_date.strftime(format) What gives? Does Python just ignore the period specifier when parsing date...

Java Date, render with specific daylight mode

I have a Java Date that is from this summer during daylight savings time. For example: Jun 01, 2009 06:00 AM PDT My question is, how do I display this date as my local time zone and current daylight savings mode (in my case Pacific Standard Time)? Jun 01, 2009 05:00 AM PST Java's Date.toString() and SimpleDateFormat displays ...

DateTime.TryParse century control C#

The result of the following snippet is "12/06/1930 12:00:00". How do I control the implied century so that "12 Jun 30" becomes 2030 instead? string dateString = "12 Jun 30"; //from user input DateTime result; DateTime.TryParse(dateString, new System.Globalization.CultureInfo("en-GB"),System.Globalization.DateTimeStyles.None...

How to encode a datetime in delphi

Hi There, I know how to use encodedate in Delphi to encode individual YY, MM and DD into a datetime field or use encodetime to encode individual HH, SS, MM and MS into datetime field but is there a way to specify both date and time into a datetime field? Coz with encodedate I cannot specify the time and with encodetime I cannot specify...

How do I find the difference between a datetime type and the current date/time in php?

I have a DATETIME for an entry in my database that is upcoming. I want to know the difference in time between the the DATETIME and the current date/time in Days, Hours, Minutes, and Seconds. I thought I might be able to use the date function to do this, but perhaps I am wrong. This was my approach: $now = mktime(0, 0, 0, date("m"), dat...

[iPhone] Formatting an NSDate

Hi, I am pulling data from an RSS Feed. One of the keys in the feed is is a string representing the date and time the item was created. I am trying to convert this string value to an NSDate. The string value is returned from the RSS feed as: 2009-11-18T22:08:00+00:00 I tried the following code to no avail: NSDateFormatter *df = [[...

PHP: Is there a function that converts a date string in a human readable format?

Hi I want to convert a date string like "19.11.2009 14:00" into the age of it now like "for 2 minutes" or "for 1 week" or "for 2 days" Is there some code around? ...