datetime

Simulate different server datetimes in PHP

Is it possible to make a PHP application think that the server datetime is offset by a large configurable amount (like 6 months ago, or 6 months from now)? Background: We have a web application that deals with sporting events and right now we would like to run it in our development environment in such a way that the web site thinks it i...

Convert Office Hours to local time using JavaScript

How can I use JavaScript to add a message like this to a web page: Our office hours are 9am - 5pm (09:00 - 17:00) PST. In your timezone, that's WWxx - YYzz (AA:00 - BB:00). Where: "WW" and "YY" are converted to the proper values for "hour" (on the 12 hour clock). "xx" and "zz" are converted to either "am" or "pm". "AA" and "...

Appropriate way to set a duration in Java

What is the appropriate way to set a duration in Java with standard Java libs? Date()? Calendar()? Example? Thanks & Cheers ER ...

How to get the time of a given city?

I know that I can display time for a particular location using only JavaScript (and no web service or external data source), but... I want to avoid using this solution because I don't want to have to account for daylight savings time, and any other factors that make it complicated. I'm looking for an easier way to display the time and a...

How can I convert a OLE Automation Date value to a date in SQL Server

My application stores dates as OLE Automation doubles with the DateTime.ToOADate() command. Now, I need to create a SQL view wich shows me the Date stored. How can I quickly convert the double to a date? Thanks ...

Date Validation in MySQL

Can anyone help me on how did MySQL can't read a rows of I've try to execute this query. SELECT * FROM attendance where '2010-07-13 00:06:00' BETWEEN timein AND timeout; This is the date in the table: +-----------------------+-----------------------+ | timein | timeout | ------------------------+---------...

"Ago" date/time functions in Ruby/Rails

Hi - I was wondering, if theres a way in rails to calculate time stamp like - half a minute ago, 2 minute ago, 1 day ego etc. Something like twitter real time date stamp. I want to know if ruby/rails has a pre-built function for such date-time conversion?? ...

Exception on ConvertTimeToUtc

Hello I have an exception when converting local time to UTC. I run my application on Windows where "Russian Standard Time" is set. public Convert() { DateTime dt = DateTime.Now; DateTime dt1 = DateTime.Now; // this converstion works TimeZoneInfo.ConvertTimeToUtc(dt, TimeZoneInfo.Local); ...

Equivalent of __DATE__ and __TIME__ in Python?

Is there an equivalent of __DATE__ and __TIME__ in Python? ...

Setting the system date in Python (on Windows)

There appears to be many packages for getting/formatting the current date, or finding out the date n time intervals from now. But I must be overlooking the existence of a simple method to set the date (like Windows' date.exe) in Python. Surely such a function exists? I've been unable to find anything on Google, the python docs (datetime...

jUI TimePicker and MySQL DATETIME column

I'm using the Martin Milesich TimePicker, which is basically the jUI datepicker with hour/minute sliders attached to it. I have a couple of queries regarding this: 1) I'm storing the data in a database field of type DATETIME - as you're probably aware the default format for this field is 2010-07-19 14:00:00. In my form field however I ...

selecting records in mysql db from 1, 7, and 30 days ago with datetime and php

Im using the following query to target results that are exactly X days older than current time. SELECT *, DATE_FORMAT(datetime, '%m/%d/%Y') FROM table WHERE datetime BETWEEN SYSDATE() - INTERVAL 30 DAY AND SYSDATE() ORDER BY ID DESC Problem is its returning data from current day if a record from ...

MsBuild ZIP Folder named by date and time actual

I'm pretty new to MSBuild so please be gentle with me, I need sample for do this: I have a msbuild file, mydeploy.targets, to deploy WebSite in remote machine. I want to do backup (of files of remote machine) for each deployment. I need ZIP a folder in remote machine, for generate ZIP file of all folder (all contents files, folders), ...

PHP: How can I make a randomDate($startDate, $endDate) function?

i have made a function which works just fine with 32-bit dates (acceptable with strtotime), but that is not scalable. i need to randomly generate peoples dates of birth, so i must use DateTime (and only <=5.2.13, to make it even more difficult) functions to generate them. here is what i had: public static function randomDate($start_dat...

How to create a regex for parsing Arabic Dates

I'm working on a program that is running a series of regexs to attempt to find a date within the DOM from a webpage. For example, in www.engadget.com/2010/07/19/windows-phone-7-in-depth-preview/, I would match "Jul 19th 2010" with my regex. Things were going fine in multiple formats and languages until I hit an arabic webpage. As an ex...

How to calculate actual months difference (calendar year not approximation) between two given dates in C#?

Example: given two dates below, finish is always greater than or equal to start start = 2001 Jan 01 finish = 2002 Mar 15 So from 2001 Jan 01 to the end of 2002 Feb months = 12 + 2 = 14 For 2002 March 15/30 = 0.5 so grand total is 14.5 months difference. It's very easy to work out by hand but how do I code it ...

How to chop a continuous date range list into a list of financial year in C#?

Example: given a continuous list of date range List[0] = from 2001 Jan 01 to 2001 Aug 14 List[1] = from 2001 Aug 15 to 2002 Jul 10 Let’s assume that a financial year is from 1st of July to 30th of June (of next year) so the output should be AnotherList[0] = from 2000 Jul 01 to 2001 Jun 30 period: 2001 Jan 01 to 2001 Ju...

Convert string timestamp (with timezone offset) to local time. . ? python

I am trying to convert a string timestamp into a proper datetime object. The problem I am having is that there is a timezone offset and everything I am doing doesn't seem to work. Ultimately I want to convert the string timestamp into a datetime object in my machines timezone. # string timestamp date = u"Fri, 16 Jul 2010 07:08:23 ...

Java date handling: store date, time and timezone in a single class

Does there exist a Java class, either in the standard libraries or third party, that allows one to store the date, time in millisecond accuracy and the timezone of the time within the same object? The features I need: Store a date, time with at least millisecond accuracy and the timezone Parse string date representations (e.g. "20...

T-SQL DateDiff - partition by "full hours ago", rather than "times minutes turned 00 since"

I have a table with timestamps, and I want to partition this table into hour-long intervals, starting at now and going backwards a couple of hours. I'm unable to get the results I need with the T-SQL DATEDIFF function, since it counts the number of times the minute hand passes 12 between the two dates - I want the number of times them mi...