date_format = "%Y-%m-%d %H:%M:%S:%f" max_timestamp = datetime.strptime(str('2018-09-28 16:01:09+00:00'), date_format)   I have tried datetime conversion string to datetime but got error this is not a correct format.  What is the exact format for this date?
419
I need to parse  strings like "2008-09-03T20:56:35.450686Z" into Python's datetime type.  I have found  in the Python standard library, but it is not very convenient.  What is the best way to do this?
75120
In a visual force page, I can take a date and do this...  &lt;apex:outputText value="{0,date, MMMM d,  yyyy}"&gt;     &lt;apex:param value="{!relatedTo.my_date__c}"/&gt; &lt;/apex:outputText&gt;   I want to be able to do that in Apex code.  So I want a method which takes a date and returns a certain format as a string.  I check the API:   and sorry if I am stupid but not so obvious how to do this?  Many thanks.
73750
I need to find out how to format numbers as strings. My code is here:  return str(hours)+":"+str(minutes)+":"+str(seconds)+" "+ampm   Hours and minutes are integers, and seconds is a float.  the str() function will convert all of these numbers to the tenths (0.1) place.  So instead of my string outputting "5:30:59.07 pm", it would display something like "5.0:30.0:59.1 pm".  Bottom line, what library / function do I need to do this for me?
62515
When I use the XML serializer to serialize a DateTime, it is written in the following format:  &lt;Date&gt;2007-11-14T12:01:00&lt;/Date&gt;   When passing this through an XSLT stylesheet to output HTML, how can I format this? In most cases I just need the date, and when I need the time I of course don't want the "funny T" in there.
17519
I have a string containing the , and I need to convert it to a Java Date object.  String date = "1081157732"; DateFormat df = new SimpleDateFormat(""); // This line try {   Date expiry = df.parse(date);  } catch (ParseException ex) {   ex.getStackTrace(); }   The marked line is where I'm having trouble. I can't work out what the argument to SimpleDateFormat() should be, or even if I should be using SimpleDateFormat().
53747
I am able to parse strings containing date/time with time.strptime  &gt;&gt;&gt; import time &gt;&gt;&gt; time.strptime('30/03/09 16:31:32', '%d/%m/%y %H:%M:%S') (2009, 3, 30, 16, 31, 32, 0, 89, -1)   How can I parse a time string that contains milliseconds?  &gt;&gt;&gt; time.strptime('30/03/09 16:31:32.123', '%d/%m/%y %H:%M:%S') Traceback (most recent call last):   File "&lt;stdin&gt;", line 1, in &lt;module&gt;   File "/usr/lib/python2.5/_strptime.py", line 333, in strptime     data_string[found.end():]) ValueError: unconverted data remains: .123
12656
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.
105204
Given a date/time as an array of (year, month, day, hour, minute, second), how would you convert it to epoch time, i.e., the number of seconds since 1970-01-01 00:00:00 GMT?  Bonus question: If given the date/time as a string, how would you first parse it into the (y,m,d,h,m,s) array?
81396
I am trying to convert a date with individual parts such as 12, 1, 2007 into a datetime in SQL Server 2005. I have tried the following:  CAST(DATEPART(year, DATE)+'-'+ DATEPART(month, DATE) +'-'+ DATEPART(day, DATE) AS DATETIME)   but this results in the wrong date. What is the correct way to turn the three date values into a proper datetime format.
26496
I want to display dates in the format: short day of week, short month, day of month without leading zero but including "th", "st", "nd", or "rd" suffix.  For example, the day this question was asked would display "Thu Oct 2nd".  I'm using Ruby 1.8.7, and  just doesn't seem to do this.  I'd prefer a standard library if one exists.
11883
How can I format a date as dd/mm/yyyy or mm/dd/yy ?   Like in VB format("dd/mm/yy",now)  How can I do this in C#?
49490
I have a tab delimited file where each record has a timestamp field in 12-hour format:     mm/dd/yyyy hh:mm:ss [AM|PM].   I need to quickly convert these fields to 24-hour time:     mm/dd/yyyy HH:mm:ss.   What would be the best way to do this? I'm running on a Windows platform, but I have access to sed, awk, perl, python, and tcl in addition to the usual Windows tools.
116296
Anytime I have to handle dates/times in java it makes me sad   I'm trying to parse a string and turn it into a date object to insert in a preparepared statement. I've been trying to get this working but am having no luck. I also get the helpful error message when I go to compile the class.  "Exception in thread "main" java.lang.Error: Unresolved compilation problem:  The method setDate(int, Date) in the type PreparedStatement is not applicable for the arguments (int, Date)"  Eh WTF?  Here is the offending code.  for(int i = 0; i &lt; flights.size(); i++){      String[] details = flight[i].toString().split(":");      DateFormat formatter ;      formatter = new SimpleDateFormat("ddMMyyyy");     Date date = formatter.parse(details[1]);       PreparedStatement pstmt = conn.prepareStatement(insertsql);     pstmt.setString(1, details[0]);     pstmt.setDate(2, date);     pstmt.setString(3, details[2] + "00");     pstmt.setString(4, details[3]);     pstmt.setString(5, details[4]);     pstmt.setString(6, details[5]);     pstmt.setString(7, details[6]);     pstmt.setString(8, details[7]);     pstmt.setString(9, details[8]);     pstmt.executeUpdate();  }
83136
The best I can come up with for now is this monstrosity:  &gt;&gt;&gt; datetime.utcnow() \ ...   .replace(tzinfo=pytz.UTC) \ ...   .astimezone(pytz.timezone("Australia/Melbourne")) \ ...   .replace(hour=0,minute=0,second=0,microsecond=0) \ ...   .astimezone(pytz.UTC) \ ...   .replace(tzinfo=None) datetime.datetime(2008, 12, 16, 13, 0)   I.e., in English, get the current time (in UTC), convert it to some other timezone, set the time to midnight, then convert back to UTC.  I'm not just using now() or localtime() as that would use the server's timezone, not the user's timezone.  I can't help feeling I'm missing something, any ideas?
99429
Is there a fairly easy way to convert a datetime object into an RFC 1123 (HTTP/1.1) date/time string, i.e. a string with the format  Sun, 06 Nov 1994 08:49:37 GMT   Using strftime does not work, since the strings are locale-dependant. Do I have to build the string by hand?
101598
I am trying to implement the python logging handler TimedRotatingFileHandler. When it rolls over to midnight it appends the current day in the form YYYY-MM-DD. LOGGING_MSG_FORMAT  = '%(name)-14s &gt; [%(levelname)s] [%(asctime)s] : %(message)s' LOGGING_DATE_FORMAT = '%Y-%m-%d %H:%M:%S'  logging.basicConfig(             level=logging.DEBUG,             format=LOGGING_MSG_FORMAT,             datefmt=LOGGING_DATE_FORMAT             ) root_logger = logging.getLogger('') logger = logging.handlers.TimedRotatingFileHandler(&quot;C:\\logs\\Rotate_Test&quot;,'midnight',1) root_logger.addHandler(logger) while True:     daemon_logger = logging.getLogger('TEST')     daemon_logger.info(&quot;SDFKLDSKLFFJKLSDD&quot;)     time.sleep(60)  The first log file created is named Rotate_Test, then once it rolls over to the next day it changes the file name to Rotate_Test.YYYY-MM-DD where YYYY-MM-DD is the current day. How can I change how it alters the filename?
23405
I have a CSV file that has dates written like this: 250909,240909 and they get stored in a SQL Server database as varchars.  How do I get it to convert them into dates so that it gets displayed like this: 25/09/09, using the dd/mm/yyyy format?  At the moment I can get it to convert, but it converts it like this: 2025/09/09, meaning it is using the yyyy/mm/dd format which is wrong, seeing that the first column is the day and second the month and third the year.