DateTime objects in many programming languages describe an instant in time, expressed as a date and time of day.
1
vote
1answer
63 views
Python - get tuple of the first and last days of the last N months
I am trying to get a tuple of date (or datetime) objects over the last N months.
My thought was to use the dateutil package with something like this:
def last_n_months(n=12, ending=None):
...
2
votes
1answer
51 views
Date formatter for javascript
I just coded this formatter to format timestamps in javascript (I tied it to underscore for convenience), any remark?
_.toDate = function(epoch, format, locale) {
var date = new Date(epoch),
...
1
vote
1answer
41 views
PHP DateTime increments, a neater / more efficient way?
I'm trying to get to grips with the DateTime class in PHP. Previously I've used date() and mktime() when playing with dates.
Here's the head of a calendar table, and I'm pretty sure I'm doing this in ...
2
votes
1answer
95 views
Leap year algorithm?
I wrote two functions for determining leap years.
("Kabisat" means "leap year" in Indonesia.)
def kabisat? y
return false if y%4!=0
return true if y%100!=0
y%400==0
end
...
3
votes
2answers
63 views
Check if the shop is open or closed
The working hours are saved in Database like
{"1" : "11:00 - 14:30", "2" : "17:30 - 23:00"}
Now i wrote a function like, which test is the shop is opened or close at the moment. Can someone please ...
0
votes
1answer
32 views
Between dates : from highest -> current -> lowest
For example I have 2 dates (year and month) like :
2013-03
2013-01 <-- Jan. current month.
2012-10
So my code is :
// Get current month and year
$m = date('m');
$y = date('Y');
// So I do ...
1
vote
1answer
328 views
jQuery countdown - accuracy
I'm using this simple plugin to show a simple countdown in my pages, what I would like is to keep it more accurate, cause somentimes it seems it isn't accurate.
This is the plugin:
/*
countdown is a ...
-2
votes
2answers
155 views
compare two date time in dd/mm/yyyy formate [closed]
I have two dates in format of dd/mm/yyyy or dd/MM/yyyy. I want to compare both date but when I am using convert.todatetime(), its not giving me proper solution.
There is any one have any idea about ...
1
vote
1answer
141 views
is my date difference calculation correct?
-(NSString *)calculateTimeDifference:(NSString *)timeStamp{
// get the current date
NSDate *date = [NSDate date];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc]init];
[dateFormat ...
2
votes
1answer
58 views
PHP: multilingual Time::since() static class
I didn't make the math myself since I'm an idiot. I did however try to make it more versatile and usable for my multilingual page, which involves making it simple to use for advanced plural forms such ...
1
vote
1answer
309 views
converting timedate timezones with jodatime
I've been struggling to get to grips with JODATIME, but feel that I've finnaly managed to get a grip on some of the functionality that I need.
I have written a function that will convert a DateTime ...
3
votes
2answers
201 views
How to improve a try on a dual Mode JavaScript textBox WaterMark?
I was just trying to make an alternate Ajax watermark from "insert date" (first mode) to "mm/dd/yyyy" (second mode).
After some trial and error, I succefully implemented a solution using JavaScript.
...
3
votes
2answers
1k views
DateTimePrecise - current DateTime with millisecond precision
Answer in this question contains DateTimePrecise class that should return current date with millisecond precision. But class is pretty bug and complicated. So I wrote my own version which seems work ...
5
votes
3answers
1k views
Java Date formatter
The (real life) problem
Following my question on SO, I found out that printing a Java Date() in a custom format is quite tedious:
final Date date = new Date();
final String ISO_FORMAT = ...
1
vote
0answers
231 views
Most elegant way to round a date to a dynamic unit of time, using only JDK 6
Question originally posted on stackoverflow here:
http://stackoverflow.com/questions/10720002/most-elegant-way-to-round-a-date-to-a-dynamic-unit-of-time-using-only-jdk-6
I'm trying to do an elegant ...
1
vote
1answer
5k views
Getting Current Time with Milliseconds (C++)
I am looking for a more efficient or shorter way to achieve the following output using the following code:
timeval curTime;
gettimeofday(&curTime, NULL);
int milli = curTime.tv_usec / 1000;
...
5
votes
3answers
343 views
Time (only) class
Working in C++ and I have some code which I'm refactoring. I have some code that needs to work with times of day but not dates. I do some juggling with time_t and struct tm but it's a pain and not ...
1
vote
2answers
333 views
Format a datetime like this “20120319”
Im working with some strange api's that requires the dates to be sent in YYYYMMDD format
I was thinking to do something like this
string date = string.Concat(DateTime.Now.Year, DateTime.Now.Month, ...