date-parsing

Why don't I get the year right using SimpleDateFormat in java ?

I trying to parse a data in a MySql Format, I ran accross SimpleDateFormat. I can get the proper day and month, but I got a strange result for the year : date = 2009-06-22; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date d = sdf.parse(date); System.println(date); System.println(d.getDate()); System.println(d.getMonth())...

Smart date interpretation.

I can't remember which application I was using, but I do recall it having really neat date parsing/interpretation. For example, you could type in 'two days ago' or 'tomorrow' and it would understand. Any libraries to suggest? Bonus points if usable from Python. ...

Fuzzy date parsing with Java

Are there any libraries for Java that allow you to interpret dates like "Yesterday", "Next Monday", ... ...

Inconsistent date parsing using SimpleDateFormat

I'm really scratching my head on this one. I've been using SimpleDateFormats with no troubles for a while, but now, using a SimpleDateFormat to parse dates is (only sometimes) just plain wrong. Specifically: SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); Date date = sdf.parse("2009-08-19 12:00:00"); System.out.prin...

How to use JSON.parse reviver parameter to parse date string

Hello all! My JSON string contains a date field that returns such a value "2009-04-04T22:55:16.0000000-04:00" I am particularly interested in parsing only the date compartment not the time. I tried using reviver function but interestingly the reviver function is never invoked! (tried on Firefox) Here is my code to accomplish that: va...

Searching Database by Arbitrary Date in PHP

Suppose you have a messaging system built in PHP with a MySQL database backend, and you would like to support searching for messages using arbitrary date strings. The database includes a messages table, with a 'date_created' field represented as a datetime. Examples of the arbitrary date strings that would be accepted by the user sho...

DateTime: Require the user to enter a time component

Checking if a user input is a valid date or a valid "date + time" is easy: .NET provides DateTime.TryParse (and, in addition, VB.NET provides IsDate). Now, I want to check if the user entered a date including a time component. So, when using a German locale, 31.12.2010 00:00 should be OK, but 31.12.2010 shouldn't. I know I could use Da...

Convert date in text format to datetime format in T-SQL

I have a client supplied file that is loaded in to our SQL Server database. This file contains text based date values i.e. (05102010) and I need to read them from a db column and convert them to a normal date time value = '2010-05-10 00:00:00.000' as part of a clean-up process. Any guidance would be greatly appreciated. ...

How do I get my Python date in the format that I want?

I'm reading a date from an Excel cell in Python (using .Value on the cell)... the result that I get is: 07/06/10 00:00:00 I thought this was a string, and so went about trying to figure out how to convert this to the format I need ("yyyyMMdd", or "20100706" in this example). However, after some playing around I realized that it is not...

How do I parse a date string in an unknown format on iphone?

How can I parse a string that represents a date and/or time using iPhone SDK if I do not know the format? I am building an application that will allow a range of possible dates and times to be used, and I don't want it to fail because the format was "01/01/2001" instead of "01-01-2001", etc. Time may or may not be included. Is there a...

Problem with date formats in JavaScript with different browsers

Hi, I am working with dates in an RSS feed, but am finding differing results when using the code below in IE, Chrome and Firefox: new Date('2001-01-01T12:00:00Z') Firefox is happy with that, but Chrome and IE return Invalid Date. I thought I'd try replacing the T and Z as follows: new Date('2001-01-01 12:00:00') This time Chrome ...

In Ruby, how to parse "9/12/2010 7:02pm"?

It seems that Time.parse will treat 9/12/2010 as December 9, 2010: irb(main):012:0> RUBY_VERSION => "1.9.2" irb(main):013:0> Time.parse('9/12/2010') => 2010-12-09 00:00:00 -0800 irb(main):014:0> Time.parse('9/12/2010 7:10pm') => 2010-12-09 19:10:00 -0800 I can use Regex to mess with the order and parse accordingly, but is there a di...