How to get the current time in Python

What is the module/method used to get the current time?

Converting string into datetime

I've got a huge list of date-times like this as strings: Jun 1 2005 1:33PM Aug 28 1999 12:00AM I'm going to be shoving these back into proper datetime fields in a database so I need to magic...

Should I use the datetime or timestamp data type in MySQL?

Would you recommend using a datetime or a timestamp field, and why (using MySQL)? I'm working with PHP on the server side.

Compare two dates with JavaScript

Can someone suggest a way to compare the values of two dates greater than, less than, and not in the past using JavaScript? The values will be coming from text boxes.

How do I calculate someone's age based on a DateTime type birthday?

Given a DateTime representing a person's birthday, how do I calculate their age in years?

Daylight saving time and time zone best practices

I am hoping to make this question and the answers to it the definitive guide to dealing with daylight saving time, in particular for dealing with the actual change overs. If you have anything to...

How to return only the Date from a SQL Server DateTime datatype

SELECT GETDATE() Returns: <code>2008-09-22 15:24:13.790</code> I want that date part without the time part: <code>2008-09-22 00:00:00.000</code> How can I get that?

Determine Whether Two Date Ranges Overlap

Given two date ranges, what is the simplest or most efficient way to determine whether the two date ranges overlap? As an example, suppose we have ranges denoted by DateTime variables StartDate1...

Calculate relative time in C#

Given a specific DateTime value, how do I display relative time, like: 2 hours ago 3 days ago a month ago

Add days to JavaScript Date

How to add days to current Date using JavaScript. Does JavaScript have a built in function like .Net's AddDay?

How do you set a default value for a MySQL Datetime column?

How do you set a default value for a MySQL Datetime column? In SQL Server it's getdate(). What is the equivalant for MySQL? I'm using MySQL 5.x if that is a factor.

How do I get the current date and time in PHP?

Which PHP function can return the current date/time?

How to sort an object array by date property?

Say I have an array of a few objects: var array = [{id: 1, date: Mar 12 2012 10:00:00 AM}, {id: 2, date: Mar 8 2012 08:00:00 AM}]; How can I sort this array by the date element in order from the...

How do I convert a datetime to date?

How do I convert a datetime.datetime object (e.g., the return value of datetime.datetime.now()) to a datetime.date object in Python?

How to subtract a day from a date?

I have a Python datetime.datetime object. What is the best way to subtract one day?

How to get the current date/time in Java

What's the best way to get the current date/time in Java?

Converting unix timestamp string to readable date

I have a string representing a unix timestamp (i.e. "1284101485") in Python, and I'd like to convert it to a readable date. When I use time.strftime, I get a TypeError: <!-- language: lang-python...

Finding the number of days between two dates

How to find number of days between two dates using PHP?

C# DateTime to "YYYYMMDDHHMMSS" format

I want to convert a C# DateTime to "YYYYMMDDHHMMSS" format. But I don't find a built in method to get this format? Any comments?

Given a DateTime object, how do I get an ISO 8601 date in string format?

Given: DateTime.UtcNow How do I get a string which represents the same value in an ISO 8601-compliant format? Note that ISO 8601 defines a number of similar formats. The specific format I am...

Convert date to datetime in Python

Is there a built-in method for converting a date to a datetime in Python, for example getting the datetime for the midnight of the given date? The opposite conversion is easy: datetime has a...

Converting a String to DateTime

How do you convert a string such as 2009-05-08 14:40:52,531 into a DateTime?

How to calculate the difference between two dates using PHP?

I have two dates of the form: Start Date: 2007-03-24 End Date: 2009-06-26 Now I need to find the difference between these two in the following form: 2 years, 3 months and 2 days How can I do...

How to print a date in a regular format?

This is my code: import datetime today = datetime.date.today() print(today) This prints: 2008-11-22 which is exactly what I want. But, I have a list I'm appending this to and then suddenly...

Get current time in seconds since the Epoch on Linux, Bash

I need something simple like date, but in seconds since 1970 instead of the current date, hours, minutes, and seconds. date doesn't seem to offer that option. Is there an easy way?

DateTime vs DateTimeOffset

Currently, we have a standard way of dealing with .NET DateTime's in a TimeZone aware way: Whenever we produce a DateTime we do it in UTC (e.g. using DateTime.UtcNow), and whenever we display one,...

How do I convert seconds to hours, minutes and seconds?

I have a function that returns information in seconds, but I need to store that information in hours:minutes:seconds. Is there an easy way to convert the seconds to this format in Python?

How can I convert a Unix timestamp to DateTime and vice versa?

There is this example code, but then it starts talking about millisecond / nanosecond problems. The same question is on MSDN, Seconds since the Unix epoch in C#. This is what I've got so...

Get current time in milliseconds in Python?

How can I get the current time in milliseconds in Python?

DateTime2 vs DateTime in SQL Server

Which one: datetime datetime2 is the recommended way to store date and time in SQL Server 2008+? I'm aware of differences in precision (and storage space probably), but ignoring those for now,...