Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert DateTime to Date

Tags:

How can I convert Date to DateTime and vice versa?

E.g.

Date dt = new Date(); 

Now I want to covert this to DateTime.

Also

DateTime dtim = new DateTime(); 

Now I want to convert it to Date.

like image 402
user93796 Avatar asked Jun 17 '09 07:06

user93796


People also ask

How do I convert datetime to date in Excel?

The following formula will help you converting date/time format cell to date only in Excel. 1. Select a blank cell you will place the date value, then enter formula =MONTH(A2) & "/" & DAY(A2) & "/" & YEAR(A2) into the formula bar and press the Enter key.

How do you convert datetime to mm dd yyyy?

string date = DateTime. ParseExact(SourceDate, "dd/MM/yyyy", CultureInfo. InvariantCulture). ToString("yyyy-MM-dd");

How do I get only date from datetime in Python?

For this, we will use the strptime() method and Pandas module. This method is used to create a DateTime object from a string. Then we will extract the date from the DateTime object using the date() function and dt.


1 Answers

Is this Joda Time's DateTime you're talking about? If so, it will be

dateTime.toDate() 
like image 144
skaffman Avatar answered Sep 20 '22 12:09

skaffman