datetime

How can I modify a Perl DateTime object?

In my script I need to make a cycle like this one: use DateTime; for $j(0..3){ my ($date) = DateTime->now->ymd; my ($k) = 0; while($k <= $j){ $date = ($date->subtract( days => 7)); $k++; } print "$date\n"; } which should get the current date, then one week ago, etc. Sadly, after getting the correct curr...

Cancel 1 instance of a repeating date

Hi, I've built a website for a local yoga studio (PHP). The site has a calendar. The instructor keeps needing to cancel a random class here and there. The problem is that we either have to cancel all the instances of a weekly repeating date to remove it from the calendar, or cancel none of them and hope that people read the announceme...

javascript date short

<script type="text/javascript">dm();</script> i am use this script it shows month October i need only oct please help me how to do it in a html page ...

Groovy Time durations

Hi, I'm trying to get the difference between 2 dates in days, hours, and seconds: import groovy.time.* Date now = new Date() // Using deprecated constructor just for this example Date newYearsDay2000 = new Date(2000, 0, 1) use (TimeCategory) { now - newYearsDay2000 } This prints: -690023 days, -14 hours, -38 minutes, -27.1...

SQlite query with datetime doesn't work

Hi, I'm working on an iPhone app. I've tried to make a simple query that works correctly on sqlite console but it doesn't work on my iPhone code. This works and it show me all the fields: const char *sqlStatement = "sessions * from animals"; This doesn't show anything, but works correctly on sql console: const char *sqlStatement = "...

SQL DateTime Overflow when using DateTime.Now + LINQ to SQL

Im getting a strange error when trying to add a new item to a table using LINQ error : SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. Code: dbc.TblEvent newEvent = new dbc.TblEvent(); newEvent.Subject = "Registered"; newEvent.PersonID = PersonId; newEvent.EventDate = Date...

Java Date Parse from one to another format

Is there a way whereby the date format can be determined in Java similar to .Net? Consider the following example: private String reformatDateString(String dateParam){ if(dateParam == null || dateParam.isEmpty()){ return null; } try{ SimpleDateFormat inDateFormat = new SimpleDateFormat("yyyy-MM-dd"); ...

SQL Server 2005 Get First and Last date for any Month in any Year.

I have a stored procedure that has to accept a month as int (1-12) and a year as int. Given those two values, I have to determine the date range of that month. So I need a datetime variable to represent the first day of that month, and another datetime variable to represent the last day of that month. Is there a fairly easy way to get th...

MySQL date range SELECT + JOIN query using column with CURRENT_TIMESTAMP

I am using this query: SELECT p.id, count(clicks.ip) FROM `p` LEFT JOIN c clicks ON p.id = clicks.pid WHERE clicks.ip = '111.222.333.444' To select clicks from table "c", that has "pid" = "p.id". The query seems to work fine, but now I want to use that query with date ranges. The "c" table has a column "time" that uses MySQL CURRENT_T...

What is the minimum time you need to Thread.Sleep( ) to ensure DateTime.Now differs ?

What is the minimum time you need to Thread.Sleep( ) to ensure DateTime.Now differs ? Given a DateTime has a Ticks property you could argue the following would suffice: Thread.Sleep(TimeSpan.FromTicks(1)); which would be fine but does this guarantee subsequent calls to DateTime.Now are not equal? UPDATE: Appears DateTime precision...

python time differences

I have two time objects Example time.struct_time(tm_year=2010, tm_mon=9, tm_mday=24, tm_hour=19, tm_min=13, tm_sec=37, tm_wday=4, tm_yday=267, tm_isdst=-1) time.struct_time(tm_year=2010, tm_mon=9, tm_mday=25, tm_hour=13, tm_min=7, tm_sec=25, tm_wday=5, tm_yday=268, tm_isdst=-1) I want to have the difference of those two? How could ...

Zend Date Weekday.

Hello. In Zend Framework I want to find a number of week day. echo Zend_Date::WEEKDAY_DIGIT; But this returns e. Today is Wednesday. And I want to return 3 (or 2 if Monday is 0). How can I do it? I know how do it with DateTime class. But I need Zend_Date. Thank you very much. ...

Find oldest/youngest datetime object in a list

I've got a list of datetime objects, and I want to find the oldest or youngest one. Some of these dates might be in the future. from datetime import datetime datetime_list = [ datetime(2009, 10, 12, 10, 10), datetime(2010, 10, 12, 10, 10), datetime(2010, 10, 12, 10, 10), datetime(2011, 10, 12, 10, 10), #future datet...

Change today's date and time in php

Is it possible to change php's current date and time (something like set_time(strtotime('1999-09-09')) so when i call time() it will return me timestamp for 1999-09-09? I need to set it globally for whole app. EDIT I already have one old app and i need to make possible to set up current date. I can't accept any custom functions. Imag...

Time zone java : San Antonio, Texas

Hi I am looking to set the timezone for San Antonio, Texas.Can some please tell me how do i set the same in my Java code. I want it in the format somewhat similar to America/New York Currently I am using TimeZone.getTimeZone("America/Denver") But "America/Denver" doesn't seem to be the right timezone for San Antonio, Texas ...

Calculating relative time offset

I was reading this article about relative time calculation The problem is that the results are wrong due to the time offset. My webpage is Greek. So how should i modify that function to work correctly, including the GMT+2 or GMT+3 hours offset? ...

In Ruby on Rails, what's the difference between DateTime, Timestamp, Time and Date?

In my experience, getting dates/times right when programming is always fraught with danger and difficulity. Ruby and Rails have always eluded me on this one, if only due to the overwhelming number of options; I never have any idea which I should pick. When I'm using Rails and looking at ActiveRecord datatypes I can find the following ...

PHP - Calculate time between dates

Hello, would like to learn how I can calculate the time between two dates. I am working on an Unlock user functionality and the following is what I have: // get offender's username from session $username = $_SESSION['UserName']; require_once('./connections/mysql.php'); $checklockoutexpiration = mysqli_query($conn,"SELECT IsLocked...

Convert UTC to days, hours minutes etc in C

I have a a long which has the time in UTC format as a timestamp for some data, now I want to convert it to this format: month 1-12 Day 1-31 24 Hour format 0-23 minute 0-59 second 0-59 subsecond nanoseconds 0-999,999,999 now the nanoseconds can obviously be set to 0 as it doesnt need to be that accurate. What is the best method to do t...

Whats the fastest way to find a consecutive day list.

i have an array of vacation dates. These are always going to be weekdays. Lets say DateTime[] dates = new DateTime[] {"1/8/2010","1/3/2010","1/6/2010","1/7/2010","1/21/2010"} i now have a single input date. Lets say: DateTime vacationDateToCheck = 1/7/2010; i want to find the vacation set (list of dates) given the set above. In ...