datetime

What will happen if I set CurrentCultureInfo to en-us

I am using a client application which connects to a remote Database in US. there are some datetime ambiguities that comes up in the result like if date is 14 Jan in database its returned as 13 Jan. What I would like to know If I Set the CurrentCultureInfo of my Client equal to my Servers will that solve the issue. If this can be done....

Consistent handling of DateTimes in different RDBMS's

Hello! I'm planning a distributed system of applications that will communicate with different types of RDBMS. One of the requirements is consistent handling of DateTimes across all RDBMS types. All DateTime values must be at millisecond precision, include the TimeZone info and be stored in a single column. Since different RDBMS's handl...

how to use TypeConverters to convert a System.Datetime to custom type

For some reason I need to cast/convert a DateTime into one of many custom objects This proves to be very difficult to do in a nice generic fashion. I am thinking of implementing an extension method on object or perhaps extending DateTimeConverter. But then what would be the generic way to handle this, I have an object and a destinatio...

How can i use PHP to show datetime without seconds

How can i change ex. 2009-01-14 06:38:18 to 2009-01-14 06:38? the column type is DATETIME. i dont wanna use SELECT DATE_FORMAT how could i do it with php? date("M-d-Y H:i", $userow['regdate']) gives: Strict Standards: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting,...

Getting DATEPART in HQL or Criteria ?

How can i get DATEPART of a time using HQL or Criteria ? I have googled it up and get some tips, but wasn't enough. If there is someone who has experienced it before, please let us know. Thanks in advance ...

Faking time without changing Windows system clock

Does anybody know of a Windows tool to report fake dates/times to a process? Apparently there are Linux programs that can be used to test how the software will react in the future / in a different timezone or to trigger scheduled tasks without actually modifying the system clock. Are there such programs for Windows? ...

C# Dates - Databases, Display and Localization

What are some Date (& Time) format best practices when wanting to adhere to localization in a new application. For example, what format do you use to write dates to the database. How do you display the following to the user using their own locale settings once the date has been obtained from the database. ShortDate LongDate DateTime ...

Java equivalent to C#'s TimeSpan

Does Java have a data type that represents a period of time eg 34 seconds, 5 minutes etc. I've seen a few implementations of a TimeSpan that cover a Time period like from the 10th of December to the 11th of December. What I need is something like TimeSpan in C#. ...

Convert 12-hour date/time to 24-hour date/time

I have a tab delimited file where each record has a timestamp field in 12-hour format: mm/dd/yyyy hh:mm:ss [AM|PM]. I need to quickly convert these fields to 24-hour time: mm/dd/yyyy HH:mm:ss. What would be the best way to do this? I'm running on a Windows platform, but I have access to sed, awk, perl, python, and tcl in addi...

Get DateTime For Another Time Zone Regardless of Local Time Zone

Regardless of what the user's local time zone is set to, using C# (.NET 2.0) I need to determine the time (DateTime object) in the Eastern time zone. I know about these methods but there doesn't seem to be an obvious way to get a DateTime object for a different time zone than what the user is in. DateTime.Now DateTime.UtcNow TimeZon...

How can I subtract a day from a python date?

I have a python datetime.datetime object. What is the best way to subtract one day? ...

Unable to parse a DateTime

I'm trying to parse a date/time string using DateTime.ParseExact. It works everywhere, except on one machine - it just will not parse on that machine. The question is: Why? What could be different on that machine so that it will cause this behaviour? Here are some things that I've already looked at: The CultureInfo is passed to DateTi...

MySQL date/time calculation

I have a date and time column in my mysql table called start_date and start_time respectively. I want my users the ability to set reminders for themselves to be sent X hours before start_time, min. 1 hour and max 24 hours. I'll be running a CRON script to send these reminders. Right now I do: SELECT * FROM auctions WHERE start_date=CUR...

Parsing Ambiguous Dates (Language Independent)

I am curious what would be the best way to handle an ambiguous date string in any given language. When pre-validating your user input isn't an option, how should MM/dd/YYYY dates be parsed? How would you parse the following ambiguous date and for what reason (statistical, cultural, etc)? '1111900' as Jan 11, 1900 [M/dd/YYYY] or Nov 1,...

How to validate a Datetime value in javascript?

How to validate a date time value in javascript to ensure that the value entered for year, month , day , hour, minute and second compose a valid Datetime object? ...

How to format a DateTime like "Oct. 10, 2008 10:43am CST" in C#

Is there a clean way to format a DateTime value as "Oct. 10, 2008 10:43am CST". I need it with the proper abbreviations and the "am" (or "pm") in lower case etc etc. I've done it myself but it's ugly so I'm looking for a different take on it. Thanks. ...

Convert System::DateTime to _timeb

I have a legacy C++-based application that timestamps incoming network traffic using the CRT _ftime() function. The _ftime() function returns a _timeb structure, which has a 32-bit and a 64-bit implementation. We are using the 32-bit implementation, which looks like this: struct _timeb { long time; // 4 bytes unsi...

How do I subtract dates?

Hi, Let's say that guy register's to my site for 5$ for 30 days. So how do I make code that automaticly after 30 days delete's his account? Thanks for answers and sorry for poor english Respectfully, Tom ...

How can I calculate the age of a person in year, month, days?

I want to calculate the age of a person given the date of birth and the current date in years, months and days relative to the current date. For example: >>> calculate_age(2008, 01, 01) 1 years, 0 months, 16 days Any pointer to an algorithm that does that will be appreciated. ...

Calculating difference in dates in Java

Hi, I find it funny that Java (or the java.util library) does not have a built-in function to calculate difference in dates. What is the best way to do this? I know the simple way is to take the difference of the time in milliseconds and then convert that into days. However, i wanted to know if this works in all cases (with daylight sav...