datetime

Print Epoch Time in Different Languages

As you may know, tonight, at exactly 23:31:30 UTC, Epoch Time will reach 1234567890! Hurray! One way of watching epoch time is by using Perl: perl -le 'while(true){print time();sleep 1;}' Can you do the same in another programming language? ...

Convert datetime?

i try to write some code: Firstly there is a textbox. if you write 13 in textbox, it equals 13.02.2009 (datetime) Secondly if datetime.now equals 15.02.2009 , you write 13 in textbox, a function return 13.03.2009. Help me thanks... ...

Calculating future occurences of Friday the 13th

I'd like to be able to start with a year, and calculate occurrences of Friday the 13th. A brute force solution is easy and obvious. I have something slightly better, but I have no doubt that someone else can come up with an elegant algorithm for this. Perhaps a little trickier, I'd be interested in giving the program a month, and have...

work out the date of the fourth saturday in the current month

Bit stuck about how to go about this one. Given the current month, I need to to return the date of the fourth saturday of each month. e.g. This month would be Feb 20th, next would be March 27th. Thanks ...

PHP - Defaulting form field value to the current date

I'm trying to default a value in a field to the current date, but my code: <?php echo '<input type="text" name="makeupassignment" size="50" value="'.date("m/d/y").'">'; ?> is only printing this: '; ?> ...

Does BETWEEN with dates actually work in SQL SERVER 2008

According to cdonner, in his answer here and on his blog. He claims that BETWEEN with date yields inconsistent results From his blog: select case when '9/1/08' between '9/1/08' and '9/15/08' then 'in' else 'out' end as s1, case when '9/1/08' between '8/28/08' and '9/1/08' then 'in' else 'out' end as s2 s1 s2 ---- ...

problem with GetDate() in asp.net

Hello all, I have problem with GetDate() method.When i am creating any new user,in DateTime field Date is coming correctly time is not coming correctly,it should show generate always system date and time.Ex:2/6/2009 12:00:00 AM,2/7/2009 12:00:00 AM,2/8/2009 12:00:00 AM etc. I mean here date is changing but system time is not changing. H...

What's the best way to make a time from "Today" or "Yesterday" and a time in Python?

Python has pretty good date parsing but is the only way to recognize a datetime such as "Today 3:20 PM" or "Yesterday 11:06 AM" by creating a new date today and doing subtractions? ...

Generate a random date between two other dates.

How would I generate a random date that has to be between two other given dates? The functions signature should something like this- randomDate("1/1/2008 1:30 PM", "1/1/2009 4:50 AM", 0.34) ^ ^ ^ date generated has date generated has random number to be after th...

Problem sorting RSS feed by date using XSL

I'm creating a website where I need to show the top 5 records from an RSS feed, and these need to be sorted by date and time. The date fields in the RSS feed are in the following format: "Mon, 16 Feb 2009 16:02:44 GMT" I'm having big problems getting the records to sort correctly - I've tried lots of different code examples I've seen, ...

php: convert milliseconds to date

I Have a string that is equal to a date, represented as the number of milliseconds since the Unix epoch. I am trying to output it into d-m-Y. The string I was given was "1227643821310", and I am told that the result should be equal to 2-12-2008, but I keep getting a result of 25-11-2008 My code is as follows: $mil = 1227643821310; $s...

Selecting empty mysql datetime fields

Is there a better way to select empty datetime fields than this? SELECT * FROM `table` WHERE `datetime_field` = '0000-00-00 00:00:00' ...

Dealing with dates in dd/mm/yyyy format

Hi there. I have a VB6 application which works with datetime values in SQL Server (which are obviously storing dates as mm/dd/yyyy). I need to represent these dates to the user as dd/mm/yyyy, read them in as dd/mm/yyyy, and then store them back into the database as the standard mm/dd/yyyy. This is the current code snippets I have whic...

Add days to DateTime using Java Script

How to add days to current DateTime using Java Script. Does Java Script have a built in function like .Net AddDay? ...

Problem with DateTime datatype

Hello all, I have problem with the DateTime data type. Through a textbox I want to add person dateofbirth. As there is no date datatype in C# i am forced to use the DateTime datatype, but while converting TxtDateofBirth to DateTime i am getting an error, "String was not recognized as a valid DateTime." Here is my conversion the code. ...

Unit testing code that does date processing based on today's date

When code processes dates based on the current date, testing should cover edge cases such as leap years as well as the more frequent month and year boundaries. In our code we always get the current date deep down in our classes using DateTime.Now (.NET, in our case). How can you unit test such code? Is this where Dependency Injection ...

Get only the Date part of DateTime in mssql

How can I get only the Date part of a DateTime ? I'm searching for something like year() function but for the whole date. ...

How do I get the number of seconds between two DateTimes in Ruby on Rails

I've got code that does time tracking for employees. It creates a counter to show the employee how long they have been clocked in for. This is the current code: start_time = Time.parse(self.settings.first_clock_in) total_seconds = Time.now - start_time hours = (total_seconds/ 3600).to_i minutes = ((total_seconds % 3600) / 60)....

Replacing a DateTime.MinValue in a DataGridView

I am working on a name record application and the information is stored in a SQLite database. All columns in the database are TEXT types, except for the date of birth column, which is a DATETIME. The original Access database that I transferred to the SQLite database allowed nulls for the date of birth, so when I copied it over, I set all...

How do I convert from MFC's COleDateTime to C# DateTime?

Hi all, I have an older library that uses COleDateTime as a return type in a C++ MFC Dll. When I do a PInvoke, can I marshal that with confidence to a DateTime object? Or should I do something wacky, like convert the COleDateTime into the number of ticks since 1970, and then convert those ticks back to a DateTime object in the C# call...