Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert string to specific datetime format?

String

"2011-05-19 10:30:14" 

To

Thu May 19 10:30:14 UTC 2011 

How can I convert specific string to this Date format ?

like image 388
krunal shah Avatar asked May 20 '11 11:05

krunal shah


People also ask

How do I convert a string to a specific format?

Print(s. ToString("MMM d, yyyy"); debug. Print(s. ToString("HH:mm:ss dddd");

How do I convert a string to a date?

Using strptime() , date and time in string format can be converted to datetime type. The first parameter is the string and the second is the date time format specifier. One advantage of converting to date format is one can select the month or date or time individually.

How do I convert ToDateTime?

open System let convertToDateTime (value: string) = try let convertedDate = Convert. ToDateTime value printfn $"'{value}' converts to {convertedDate} {convertedDate.


1 Answers

require 'date'  date = DateTime.parse("2011-05-19 10:30:14") formatted_date = date.strftime('%a %b %d %H:%M:%S %Z %Y') 

See strftime() for more information about formatting dates.

like image 77
Pär Wieslander Avatar answered Sep 27 '22 16:09

Pär Wieslander