datetime

Datetime To Unix timestamp

Is there anyone sitting on a PHP function to convert a date of format 0000-00-00 00:00:00(datetimesql) to unix timestamp? Thanks in advance. ...

Leading Zero Date Format C# (asp.net)

I have this function... private string dateConvert(string datDate) { System.Globalization.CultureInfo cultEnGb = new System.Globalization.CultureInfo("en-GB"); System.Globalization.CultureInfo cultEnUs = new System.Globalization.CultureInfo("en-US"); DateTime dtGb = Convert.ToDateTime(datDate, cultEnGb.DateTimeF...

Inserting DATETIME with ActiveRecord and MySQL

I am having a problem with ActiveRecord inserting the DATETIME as per the documentation; "Active Record automatically timestamps create and update operations if the table has fields named created_at/created_on or updated_at/updated_on." I have a column named created_at but ActiveRecord is not inserting the DATETIME. My insert query looks...

C#: What is the best way to convert seconds into (Hour:Minutes:Seconds:Milliseconds) time?

What is the best way to convert seconds into (Hour:Minutes:Seconds:Milliseconds) time? Let's say I have 80 seconds, are there any specialized classes/techniques in .NET that would allow me to convert those 80 seconds into (00h:00m:00s:00ms) format like to DateTime or something? ...

How do I get a specific TIME_ZONE_INFORMATION struct in Win32?

The Win32 GetTimeZoneInformation function returns your systems local time zone as set up in the control panel. How do I get another specific time zone? Is there a call that does this? Tony ...

Convert unix timestamp to julian

How can I convert from a unix timestamp (say 1232559922) to a fractional julian date (2454853.03150). I found a website ( http://aa.usno.navy.mil/data/docs/JulianDate.php ) that performs a similar calculation but I need to do it programatically. Solutions can be in C/C++, python, perl, bash, etc... ...

Converting string into datetime

Short and simple. I've got a huge list of date-times like this as strings: Jun 1 2005 1:33PM Aug 28 1999 12:00AM I'm going to be shoving these back into proper datetime fields in a database so I need to magic them into real datetime objects. Any help (even if it's just a kick in the right direction) would be appreciated. Edit: Thi...

Natural language parser for dates (.NET)?

I want to be able to let users enter dates (including recurring dates) using natural language (eg "next friday", "every weekday"). Much like the examples at http://todoist.com/Help/timeInsert I found this post, but it's a bit old and offered only one solution that I'm not entirely content with. I thought I'd resurrect this question and ...

Best way to parse DateTime to SQL server

I was wondering what is the best way to parse a DateTime object to your SQL server. Where you are generating the SQL in code. I have always used something like DateTime.Now.TolongDateString() and had good results, apart from today where i got a error, and it made me think. System.Data.SqlClient.SqlException: Conversion failed when ...

What are the pros and cons of the various date/time field types in MySQL?

Date and time in MySQL can be stored as DATETIME, TIMESTAMP, and INTEGER (number of seconds since 01/01/1970). What are the benefits and drawbacks of each, particularly when developing under a LAMP stack? ...

Rails is ignoring the time part of my datetime column

For some reason I can't save a Time to MySQL. My Column is a datetime and I've also tried using a timestamp when I was testing. Here's my console session below: $ ./script/console Loading development environment (Rails 2.1.0) >> Event.find 1 # Event id: 1, name: "Meeting at XXX", start_date: "2009-01-17" >> e.start_date = Time.now => T...

How can I convert string to datetime with format specification in JavaScript?

How can I convert a string to a date time object in javascript by specifying a format string? I am looking for something like: var dateTime = convertToDateTime("23.11.2009 12:34:56", "dd.MM.yyyy HH:mm:ss"); ...

Java: calculating duration

I created the following code to calculate the duration between two timestamps which can come in two different formats: public class dummyTime { public static void main(String[] args) { try { convertDuration("2008-01-01 01:00 pm - 01:56 pm"); convertDuration("2008-01-01 8:30 pm - 2008-01-02 09:30 am"); } catch (Exception e) { e.p...

Work out the percentage of the day that has elapsed

Slightly strange question, but hopefully someone can help. In essence, if the time was 12pm the the elapsed percentage would be 50%, 6am would be 25% and 16pm would be 75%. Given the current time, how could you work out the amount of day that already passed? ...

How do you read the system time and date in Perl?

I need to read the system clock (time and date) and display it in a human-readable format in Perl. Currently, I'm using the following method (which I found here): #!/usr/local/bin/perl @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); @weekDays = qw(Sun Mon Tue Wed Thu Fri Sat Sun); ($second, $minute, $hour, $dayOfMonth, $...

Is there a good *strict* date parser for Java?

Is there a good, strict date parser for Java? I have access to Joda-Time but I have yet to see this option. I found the "Is there a good date parser for Java" question, and while this is related it is sort of the opposite. Whereas that question was asking for a lenient, more fuzzy-logic and prone to human error parser, I would like a ...

SQL Drop Time in DateTime

Hi, I have a problem where my table stores the date as 2009-01-10 10:00:00.000 and I have another table which stores the date as 2009-01-10 12:00:00.000 I know they are not the same but the dates are, is there away in SQL to easily drop the time and keep just the dates for comparison? Thanks. ...

Respecting on-the-fly changes to Windows time format.

I am working on a C# app that tries to respect the time format of the system it is running on. If the Windows control panel is changed to 24 hour format, that is the format the app will display time in. Anyway, it does this successfully, except it will only work if the time format is changed before the app is run. If you change the Wi...

DB Performance and data types

I'm supporting an existing application written by another developer and I have a question as to whether the choices the data type the developer chose to store dates is affecting the performance of certain queries. Relevant information: The application makes heavy use of a "Business Date" field in one of our tables. The data type for t...

AM/PM Column Name

Without arguing the relative merits of storing a datetime this way... If you had a column where you stored AM or PM what would you call that column? EDIT: I should have figured that there'd be a group of you who couldn't resist being snarky about the idea... Nowhere do you see that I'm about to do this, that I want to do this, that I'...