datetime-format

Convert C# DateTime to Javascript Date

余生长醉 提交于 2019-12-03 05:30:26
问题 I have a function in Javascript that receives a C# DateTime from MVC. If the date is null it should return "-", if it's a valid date it should return the formated date. IMPORTANT: It's not possible to send the date in another format from C#. Javascript: function CheckDate(date) { if (date == "Mon Jan 01 0001 00:00:00 GMT+0000 (GMT Daylight Time)") return "-"; else { var dat = new Date(date); return dat.getFullYear() + dat.getMonth() + dat.getDay(); } Is there a better way to compare if the

How can I create basic timestamps or dates? (Python 3.4)

感情迁移 提交于 2019-12-03 04:05:00
问题 As a beginner, creating timestamps or formatted dates ended up being a little more of a challenge than I would have expected. What are some basic examples for reference? 回答1: Ultimately you want to review the datetime documentation and become familiar with the formatting variables, but here are some examples to get you started: import datetime print('Timestamp: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now())) print('Timestamp: {:%Y-%b-%d %H:%M:%S}'.format(datetime.datetime.now())) print

DateTime formatting 3 letter month

若如初见. 提交于 2019-12-02 19:57:25
问题 The code below returns the date in this format - 21-03-2014. We need it to return the date in this format - 21-MAR-2014. Three letter text designation. Current time would be nice but not critical. What changes need to be made? function onOpen() { var ui = DocumentApp.getUi(); // Or FormApp or SpreadsheetApp. ui.createMenu('Custom Menu') .addItem('Insert Date', 'insertDate') .addToUi(); } function insertDate() { var cursor = DocumentApp.getActiveDocument().getCursor(); if (cursor) { // Attempt

Store Date Format in elasticsearch

允我心安 提交于 2019-12-02 18:58:05
I met a problem when I want to add one datetime string into Elasticsearch. The document is below: {"LastUpdate" : "2013/07/24 00:00:00"} This document raised an error which is "NumberFormatException" [For input string: \"20130724 00:00:00\"] I know that I can use the Date Format in Elasticsearch, but I don't know how to use even I read the document on the website. {"LastUpdate": { "properties": { "type": "date", "format": "yyyy-MM-dd"} } } and {"LastUpdate": { "type": "date", "format": "yyyy-MM-dd" } } are wrong. How can I transfer the datetime string into date format in Elasticsearch? How can

Convert C# DateTime to Javascript Date

眉间皱痕 提交于 2019-12-02 18:47:52
I have a function in Javascript that receives a C# DateTime from MVC. If the date is null it should return "-", if it's a valid date it should return the formated date. IMPORTANT: It's not possible to send the date in another format from C#. Javascript: function CheckDate(date) { if (date == "Mon Jan 01 0001 00:00:00 GMT+0000 (GMT Daylight Time)") return "-"; else { var dat = new Date(date); return dat.getFullYear() + dat.getMonth() + dat.getDay(); } Is there a better way to compare if the date is the C# New DateTime? And how do I parse and return the date in "yyyy/MM/dd" format? Given the

How can I create basic timestamps or dates? (Python 3.4)

蓝咒 提交于 2019-12-02 17:25:13
As a beginner, creating timestamps or formatted dates ended up being a little more of a challenge than I would have expected. What are some basic examples for reference? Ultimately you want to review the datetime documentation and become familiar with the formatting variables, but here are some examples to get you started: import datetime print('Timestamp: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now())) print('Timestamp: {:%Y-%b-%d %H:%M:%S}'.format(datetime.datetime.now())) print('Date now: %s' % datetime.datetime.now()) print('Date today: %s' % datetime.date.today()) today = datetime

Standard formatting Vs Custom formatting in UltragridCells

谁说我不能喝 提交于 2019-12-02 14:14:47
问题 I'm trying to format a Ultragridcell using the following code and it works fine. //Code DefaultEditorOwnerSettings editorSettings; DateTimeEditor datetime_editor; editorSettings = new DefaultEditorOwnerSettings() editorSettings.DataType = typeof(DateTime); editorSettings.MaskInput = "mm/dd/yyyy"; datetime_editor = new DateTimeEditor(new DefaultEditorOwner(editorSettings)); e.Row.Cells["DateInfo"].Editor = datetime_editor; But when I try to format like the below code, it fails. //Code

How to specify which century a date should be parsed in Joda-Time

不打扰是莪最后的温柔 提交于 2019-12-02 14:13:45
问题 I have some HR records whose dates are formatted as dd/MM/yy , and I am normalizing them to dd-MM-yyyy using Joda-Time. So for example, the following records are normalized as follows Input Output 30/01/14 --> 30-01-2014 15/07/99 --> 15-07-1999 24/03/84 --> 24-03-1984 Based on various criteria (average length of human lifespan, when company has been around, ... ), I can assume what year 99 might refer to. However, if I wanted to specify that 99 refers to 1899 or some other year ending in 99 ,

How to convert getTime() to 'YYYY-MM-DD HH24:MI:SS' [duplicate]

回眸只為那壹抹淺笑 提交于 2019-12-02 13:25:44
This question already has an answer here: Convert timestamp in milliseconds to string formatted time in Java 9 answers I Have the following code in my application System.out.println(rec.getDateTrami().getTime()); I need to convert the following format (I suppose that they are seconds) 43782000 29382000 29382000 To a format YYYY-MM-DD HH24:MI:SS , anyone can help to me? Jonas Michel You can make use of the SimpleDateFormat Example: SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); Date date = new Date(); date.setTime(rec.getDateTrami().getTime()); System.out.println(format

How to get day, month, year and hour, minutes, second from DateTime format?

匆匆过客 提交于 2019-12-02 12:07:30
I tried this following code but its a deprecated in android SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); try { Date date1 = simpleDateFormat.parse("11/20/2014 8:10:00 AM"); Log.e("date", "" + date1.getYear()); Log.e("month", "" + date1.getmonth()); Log.e("year", "" + date1.getYear()); Log.e("hour", "" + date1.getHours()); Log.e("minutes", "" + date1.getMinutes()); Log.e("seconds", "" + date1.getSeconds()); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } Its is deprecated how to use calendar and get day, month, year? Set