datetime

attribute 'tzinfo' of 'datetime.datetime' objects is not writable

How do I set the timezone of a datetime instance that just came out of the datastore? When it first comes out it is in UTC. I want to change it to EST. I'm trying, for example: class Book( db.Model ): creationTime = db.DateTimeProperty() When a Book is retrieved, I want to set its tzinfo immediately: book.creationTime.tzinfo =...

Printing correct time using timezones, Python

Extends Ok, we are not having a good day today. When you attach the correct tzinfo object to a datetime instance, and then you strftime() it, it STILL comes out in UTC, seemingly ignoring the beautiful tzinfo object I attached to it. # python 2.5.4 now = datetime.now() print now.strftime( "%a %b %d %X" ) # %X is "locale's...

Find time duration

I have two date fields with times.They are 1.2008-06-09 10:18:00.000 2.2008-06-10 11:20:00.000 I have to find the difference between the above two dates in the format - "24 hour:2 minutes:0 seconds" Is there any method to get this result in sql 2000? ...

Time difference between 2 dates ignoring weekend time

Given 2 dates, how can i calculate the number of hours/minutes between them, excluding weekend time (since Friday 17:30 till Monday 09:00) The script queries a MySql database but i assume this sort of calculations would be easier in php. I'm thinking of a iterative function to determine the weekday and keep looping until last date would...

The first day of the current month in php using date_modify as DateTime object

I can get Monday this week with: $monday = date_create()->modify('this Monday'); I would like to get with the same ease the 1st of this month. How can I achieve that? Thanks ...

How do you change the timezone in PHP for an existing timestamp?

The code for the date and time function: function date_and_time($format,$timestamp) { $date_and_time = date($format,$timestamp); return $date_and_time; } And then the code to display it: <?php echo date_and_time("dS F Y", strtotime($profile[last_activity_date_and_time])); ?> The value of $profile[last_activity_d...

asp.net mvc: SQLDateTimeOverflow problem with Entity Framework

I'm trying to update an object, and getting: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. There are two fields in the object that are DateTime objects, and they're set with: obj.created_date = DateTime.Now; obj.modified_date = DateTime.Now; Except that everything looks reasonable when ...

php convert datetime to UTC

I am in need of an easy way to convert a date time stamp to UTC (from whatever timezone the server is in) HOPEFULLY without using any libraries. ...

jQuery datepicker changing input value automatically

So I'm building an application where data is coming back from a database where the date could be in many different formats, ie '2008', '05/22/99', '8/20/2004'. And lets say, for example, a user wants to edit a date (2009) by clicking the "Edit" button. Well in the edit window it SHOULD show an input box with the year '2009' already prese...

Should DateTime be stored in UTC or local time(of server) in a website that is accessible all over the world. what is the pros and cons of each approach.

Please kindly explain what is the impact of the system like shopping cart in which one customer(buyer) sits in one timezone and the other(seller) is on other timezone and the date is changed at one end. so the report data for one customer who bought is different than the other. ...

SPARQL xsd:dateTime equality

I have a SPARQL query: PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#&gt; PREFIX person: <http://www.myOntDomain/person#&gt; PREFIX likedEvent: <http://www.myOntDomain/likedEventRule#&gt; PREFIX event: <http://www.myOntDomain/event#&gt; PREFIX owl: <http://www.w3.org/2002/07/owl#&gt; PREFIX xsd: <http://www.w3.org/2001/XMLS...

GWT java.util.Date serialization bug

GWT doesn't serialize Java Date properly. When I tried sending Date created in Javascript through the wire, I found out that dates between April 1st (funny) and 25th October for years before year 1983 get subtracted by one day. That means that, say, both 1982-04-01 and 1982-03-31 become 1982-03-31 on the Java side. Given the dates in q...

How can I convert yyyy-mm-dd hh:mm:ss into UTC in Perl?

convert datetime format yyyy-mm-dd hh:mm:ss (Might be a string) into UTC, Looking into DateTime but I don't see how to parse the string? UPDATE: Is this working correctly? require 5.002; use strict; use warnings; use DateTime::Format::DateManip; my $string = '2010-02-28 00:00:00'; my @dates = ( $string ); for my $date ( @date...

Optimal way to store datetime values in SQLite database (Delphi)

I will be storing datetime values in an SQLite database (using Delphi and the DISqlite library). The nature of the db is such that it will never need to be transferred between computers or systems, so interoperability is not a constraint. My focus instead is on reading speed. The datetime field will be indexed and I will be searching on ...

Comparing date time

Hi. It seems I can't compare 2 date values with time. When I compare just date part - year, month and day - everything works fine. But when I add comparing times everything breaks down and not even month fits. So what's some basic algorithm for comparing 2 dates? I mean generally, I can't juse use dateTime1.CompareTo(dateTime2). Prefer...

Get current date and time in seconds

time_t rawtime; struct tm *mytm; time_t result; time(&rawtime); mytm=localtime(&rawtime); mytm->tm_mon=month-1; mytm->tm_mday=day; mytm->tm_year=year-1900; mytm->tm_sec=0; mytm->tm_min=0; mytm->tm_hour=0; result = mktime(mytm); Above code snippet,I'm expecting result to display the no.of seconds lapsed since 1970,jan-1st for th...

Converting dates in AWK

I have a file containing many columns of text, including a timestamp along the lines of "Fri Jan 02 18:23" and I need to convert that date into MM/DD/YYYY HH:MM format. I have been trying to use the standard 'date' tool with awk getline to do the conversion, but I can't quite figure out how to pass the fields into the 'date' command in ...

How to handle time difference in ASP.Net (MVC)?

Hey! I've published a web application to a server in the USA. The app is actually for swedes (people in Sweden) and I am looking for the best way to hadle the time difference. There's a +7 hour difference. Should I store the DateTime.Now in DB as it is, or should I use DateDiff to change the time before creating each record? What's t...

How can I format datetime values in SQL Server?

hi How can I format the following datetime values: 2010-01-21 00:00:00.000 - as - 21/01/2010 and 1900-01-01 09:09:18.000 - as - 09:09:18 ...

Easy to use time-stamps in Python

I'm working on a journal-type application in Python. The application basically permits the user write entries in the journal and adds a time-stamp for later querying the journal. As of now, I use the time.ctime() function to generate time-stamps that are visually friendly. The journal entries thus look like: Thu Jan 21 19:59:47 2010 Di...