datetime

C# datetime format that includes date/month/year and not day

Another silly question, but I wanted to use a standard date format that displays date, month and year in the standard regional settings of the pc. However I could only find "D" which lists day along with Date-Month-Year. Is there any way I can remove the day from it or any other way to get my desired output? DateTime date1 = new DateTim...

handling BC dates in Ruby on Rails

Hello, I'm planning to make an application that needs to store dates way before 1970. Maybe even BC dates. Do you think I should store and handle that manually or can I use the Date/Time classes in Rails or use some plugin? Thanks, Tam ...

PHP function to get the date format?

I know how to use date format strings, to turn date('Y/m/d H:i:s'); into 2009/12/18 11:37:45. I would like a function that can do the opposite - look at a formatted date then return the format. Is there one in PHP? The reason is we have timestamps saved in our database in a variety of formats and I am writing a tool processing all of ...

How can I determine if iPhone is set for 12 hour or 24 hour time display?

I thought I saw something answering this on SO recently but now I can't find it. Here is the code I am using now to determine if settings are for 24 hour time display. It works for me in the US, but I don't know if it will work in all locales. Is this sufficient or is there a better way to find out the current setting for this? +(BOO...

Is there any other time service than system time that we can make use?

I am developing a desktop app and it have an trial period after which application will get expire. Currently I am using system time. Since user can easily change it, I thought its not a good way to follow. Is there any other time service that is available which I can make use of? I heard something like system clock count or something l...

what is the correct way to format a datetime in SQL server datetime field

I have a dateTime object in C# and i want to do an insert into SQL Server datetime field. What is the correct format for this? ...

MySQL auto-store datetime for each row

Lately I've been doing quite a few projects that require the use of back-end, including MySQL. However I'm quite sick of adding the columns dt_created and dt_modified (which are date time stamps for creation and last modified respectively) to all the tables I have in my database. Everytime I INSERT or UPDATE the database, I will have t...

Any utility in the JDK to format a timezone into a specific string

I will be retrieving values from the range -12 to +12 & I need to convert it to a specific timezone format string. e.g. -3 becomes -03:00 0 becomes Z 4 becomes +04:00 Is there any readymade utility that I've overlooked that does the same thing in JDK6 ? Thanks ...

Convert a date to string in Javascript

I'm looking for a way to convert a Javascript Date object to a string. I'm converting my site from Ruby to server side Javascript, and I'm looking for something analogous to strftime in Ruby, C, and many other languages. I found plenty of simple scripts that do this kind of conversion, but I'd prefer not to include a custom implementati...

How do I insert datetime value into a SQLite database?

I am trying to insert a datetime value into a SQLite database. It seems to be sucsessful but when I try to retrieve the value there is an error: <Unable to read data> The SQL statements are: create table myTable (name varchar(25), myDate DATETIME) insert into myTable (name,mydate) Values ('fred','jan 1 2009 13:22:15') ...

timeIntervalSinceDate problem

Hi guys - last resort this as I cannot for the life of me work it out! I am setting a date when my app is closed (using applicationWillTerminate) in user defaults NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSDate *timeClosed = [[NSDate alloc] init]; [defaults setObject: timeClosed forKey:@"svdTimeClosedApp"]; t...

how to test date and datetime with mysql

hi guys, My table is using a datetime (YYYY-MM-DD HH:MM:SS) and i need to display today's entries. my code is only : SELECT * FROM table WHERE date = '$date' ORDER BY score DESC with $date = date("Y-m-d"); well, as expected it doesnt work :| you guys have a solution here ? ...

How to convert WMI DateTime to standard DateTime?

I'm trying to read the install date from WMI (Win32_OperatingSystem.InstallDate). The return value looks like this: 20091020221246.000000+180. How can I get a valid Date? ...

Timestamp to internal day count

On one project, I have an internal calculation of times. The days since the launch are simply enumerated: 2009/10/19: launch day 2009/10/20: day 1 2009/10/21: day 2 etc. Now I would like to have a function which gives me the current day of the internal calculation of times. E.g. "day 129" on one day in 2010. But it is important to ha...

Convert date to datetime in Python

Silly question, but is there a built-in method for converting a date to a datetime in Python, ie. getting the datetime for the midnight of the date? The opposite conversion is easy - datetime has a .date() method. Do I really have to manually call datetime(d.year, d.month, d.day) ? Edit: and the winner is: datetime.combine(d, time()) ...

DateTime Problem in Rails Unit Tests

I'm working on unit tests for my Rails app and have run into the following problem. I have an Event model with a fixture that boils down to: concert: name: Wallflowers start_at: <%= DateTime.new(1999) %> In my unit test, I have the following assertion: assert_equal DateTime.new(1999), events(:concert).start_at The te...

How do I pull values between two datetimes at specific interval in MySQL?

I have an application that writes temperature values to a MySQL table every second, It consists of the temperature and a datetime field. I need to pull these values out of the table at specific intervals, every second, minute, hour etc. So for example I will need to pull out values between 2 datetime fields and show the temperature at ...

Ignoring the time element of a datetime field

I have a datetime field in my table. I want to delete records based on a date but I am not interested in the time element. How would I write the SQL for this ? I am using MS SQL 2008. ...

Convert an RFC 3339 time to a standard Python timestamp

Is there an easy way to convert an RFC 3339 time into a regular Python timestamp? I've got a script which is reading an ATOM feed and I'd like to be able to compare the timestamp of an item in the ATOM feed to the modification time of a file. I notice from the ATOM spec, that ATOM dates include a time zone offset (Z<a number>) but, in ...

rails datetime in sperate fields

I may have over-complicated what i need to do but this is what i now have. I jab a jobs controller that have 2 fields starts_at as DATETIME end_time as DATETIME I save the event_date in a form using a calendar_date_select :starts_at ,:time => false I save the date time as time_select :starts_at, {:twelve_hour => true} This sa...