dates

Localising date format descriptors

What is the best way to localise a date format descriptor? As anyone from a culture which does not use the mm/dd/yyyy format knows, it is annoying to have to enter dates in this format. The .NET framework provides some very good localisation support, so it's trivial to parse dates according to the users culture, but you often want to al...

What is the best way to wrap time around the work day?

I have a situation where I want to add hours to a date and have the new date wrap around the work-day. I cobbled up a function to determine this new date, but want to make sure that I'm not forgetting anything. The hours to be added is called "delay". It could easily be a parameter to the function instead. Please post any suggestions. ...

Date arithmetic in Unix shell scripts

I need to do date arithmetic in Unix shell scripts that I use to control the execution of third party programs. I'm using a function to increment a day and another to decrement: IncrementaDia(){echo $1 | awk 'BEGIN { diasDelMes[1] = 31 diasDelMes[2] = 28 diasDelMes[3] = 31 diasDelMes[4] = 30 diasDel...

T-Sql date format for seconds since last epoch / formatting for sqlite input

I'm guessing it needs to be something like: CONVERT(CHAR(24), lastModified, 101) However I'm not sure of the right value for the third parameter. Thanks! ...

Creation Date of Compiled Executable (VC++ 2005)

The creation date of an executable linked in VS2005 is not set to the real creation-date of the exe-file. Only a complete re-build will set the current date, a re-link will not do it. Obviously the file is set to some date, which is taken from one of the project-files. So: is there a way to force the linker to set the creation-date to ...

Dealing with PHP server and MySQL server in different time zones

For those of us who use standard shared hosting packages, such as GoDaddy or Network Solutions, how do you handle datetime conversions when your hosting server (PHP) and MySQL server are in different time zones? Also, does anybody have some best practice advice for determining what time zone a visitor to your site is in and manipulating...

How to display "12 minutes ago" etc in a PHP webpage?

Can anyone tell me how I can display a status message like "12 seconds ago" or "5 minutes ago" etc in a web page? ...

If I have a PHP string in the format YYYY-DD-MM and a timestamp in MySQL, is there a good way to convert between them?

I'm interested in doing comparisons between the date string and the MySQL timestamp. However, I'm not seeing an easy conversion. Am I overlooking something obvious? ...

Ruby / Rails pre-epoch dates on windows

Working with dates in ruby and rails on windows, having problems with pre-epoch dates (before 1970) throwing out of range exceptions. Tried using both Time and DateTime objects but continuing to have the same problems. ...

How can I format a javascript date to be serialized by jQuery

I am trying to set a javascript date so that it can be submitted via JSON to a .NET type, but when attempting to do this, jQuery sets the date to a full string, what format does it have to be in to be converted to a .NET type? var regDate = student.RegistrationDate.getMonth() + "/" + student.RegistrationDate.getDate() + "/" + student.Re...

What's the simplest way to decremement a date in Javascript by 1 day?

I need to decrement a Javascript date by 1 day, so that it rolls back across months/years correctly. That is, if I have a date of 'Today', I want to get the date for 'Yesterday'. It always seems to take more code than necessary when I do this, so I wonder if there's a simple way. What's the simplest way of doing this? [Edit: Just t...

How do i get today's date in C# in 8/28/2008 format?

How do i get today's date in C# in 8/28/2008 format? I need to set a string variable to today's date (preferably without the year) but there's got to be a better way than building it month-/-day once piece at a time. Edit: BTW: I'm in the US so M/dd would be correct e.g. September 11th is 9/11. Note: an answer from kronoz came in that ...

What is the regex pattern for datetime (2008-09-01 12:35:45 ) ?

Dont have any additional information. Just what is the regex pattern for datetime (2008-09-01 12:35:45 ) ? @Espo : I get this error : No ending delimiter '^' found using: preg_match('(?n:^(?=\d)((?31(?!(.0?[2469]|11))|30(?!.0?2)|29(?(.0?2)(?=.{3,4}(1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|(16|[2468][048]|[3579][26])00))|0?[1-9]|...

sql missing rows when grouped by DAY, MONTH, YEAR

If I select from a table group by the month, day, year, it only returns rows with records and leaves out combinations without any records, making it appear at a glance that every day or month has activity, you have to look at the date column actively for gaps. How can I get a row for every day/month/year, even when no data is present, i...

How do I get the difference between two Dates in JavaScript?

I'm creating an application which lets you define events with a time frame. I want to automatically fill in the end date when the user selects or changes the start date. I can't quite figure out, however, how to get the difference between the two times, and then how to create a new end Date using that difference. ...

Get Last Day of the Month in Python

Is there a way using Python's standard library to easily determine (i.e. one function call) the last day of a given month? If the standard library doesn't support that, does the dateutil package support this? ...

How do You Build a Date or Calendar Object From a String in Java?

I have a string representation of a date that I need to create an object from. I've looked through Date and Calendar API but haven't found anything that can do this other than creating my own ugly parse method. I know there must be a way, does anyone know of a solution? ...

How Would You Programmatically Create a Pattern from a Date that is Stored in a String?

I have a string that contains the representation of a date. It looks like: Thu Nov 30 19:00:00 EST 2006 I'm trying to create a Date object using SimpleDateFormat and have 2 problems. 1.) I can't figure out the pattern to hard-code the solution into the SimpleDateFormat constructor 2.) I can't find a way I could parse the string usi...

Batch file to delete files older than N days

I am looking for a way to delete all files older than 7 days in an MS-DOS batch file. I've search around the web, and found some examples with hundreds of lines of code, and others that required installing extra command line utilities to accomplish the task. Similar things can be done in BASH in just a couple lines of code. It seems ...

Regular Expression to match valid dates

I'm trying to write a regular expression that validates a date. The regex needs to match the following M/D/YYYY MM/DD/YYYY Single digit months can start with a leading zero (eg: 03/12/2008) Single digit days can start with a leading zero (eg: 3/02/2008) CANNOT include February 30 or February 31 (eg: 2/31/2008) So far I have ^(([1-9]...