date

substr() is not working as expected

纵然是瞬间 提交于 2020-07-03 04:35:16
问题 I am just trying to extract the date's year , month and day separately so that I can use it as per my wish. I stored the current date in $today and used substr() to extract the strings from it. But I am getting some strange behaviour from what I am doing. My current code: $today = date("Y/m/d"); $_year = substr($today, 0,4); $_month = substr($today, 5,7); $_day = substr($today, 8, 10); echo $_year . " " . $_month; The $_year works correctly as expected but the problem arises from $_month , no

Android: Compare time in this format `yyyy-mm-dd hh:mm:ss` to the current moment

风格不统一 提交于 2020-07-02 18:12:12
问题 I want to get the current time on the device in the format: 2013-10-17 15:45:01 ? The server sends me the date of an object in the format above as a string. Now i want to get the phones current time and then check if there is a difference of say more than 5 minutes? So A: How can i get the devices current time in this fomat: 2013-10-17 15:45:01 B how can I work out the difference between the two. 回答1: You can use SimpleDateFormat to specify the pattern you want: new SimpleDateFormat("yyyy-MM

Conversion of Teradata sql to MYSQL sql

假装没事ソ 提交于 2020-06-29 05:17:36
问题 I want to convert Teradata query into MYSQL query. Datatype of START_TIME AND END_TIME is TIMESTAMP(6) Teradata query:- select START_TIME,END_TIME, (EXTRACT(DAY FROM (END_TIME - START_TIME DAY(4) TO SECOND)) * 86400) from base.xyz Result is like:- **START_TIME, END_TIME, CALCULATED_FIELD** 9/15/2017 16:22:52.000000 9/19/2017 15:14:02.000000 259,200 7/26/2014 07:00:04.000000 7/28/2014 12:55:55.000000 172,800 6/8/2018 16:59:19.000000 6/11/2018 09:56:23.000000 172,800 10/6/2017 17:52:06.000000

Conversion of Teradata sql to MYSQL sql

∥☆過路亽.° 提交于 2020-06-29 05:17:29
问题 I want to convert Teradata query into MYSQL query. Datatype of START_TIME AND END_TIME is TIMESTAMP(6) Teradata query:- select START_TIME,END_TIME, (EXTRACT(DAY FROM (END_TIME - START_TIME DAY(4) TO SECOND)) * 86400) from base.xyz Result is like:- **START_TIME, END_TIME, CALCULATED_FIELD** 9/15/2017 16:22:52.000000 9/19/2017 15:14:02.000000 259,200 7/26/2014 07:00:04.000000 7/28/2014 12:55:55.000000 172,800 6/8/2018 16:59:19.000000 6/11/2018 09:56:23.000000 172,800 10/6/2017 17:52:06.000000

Convert 2015-06-01T02:31:00+0000 to DateTime object c#

喜夏-厌秋 提交于 2020-06-29 05:03:10
问题 I'm writting an app that consume this webservice: http://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote?format=json as you can see there, the JSON object comes with an utc datetime field. I want to save this information in a simple DateTime object with the following format "yyyy-MM-dd HH:mm:ss". This is my code: DateTime dateParsed = DateTime.Now; DateTime.TryParseExact((string)resource.SelectToken("resource").SelectToken("fields")["utctime"], "yyyy'-'MM'-'dd'T'HH':'mm':'ssz",

Droid API 22+ options for Date/Duration (in Kotlin)?

China☆狼群 提交于 2020-06-29 04:43:45
问题 I'm porting an iOS app to Android, target API 22. I do a bunch of Date/TimeInterval stuff. I do it all in UTC so it just works for me. I'm struggling with what to use for Android. There's Date (from the beginning of time, ha ha). I guess I could do duration math by converting to/from the time milliseconds attribute. It's not clear to me what zone/rules apply to those. I see people who seem to use Calendars as Date objects and pass those around. That seems a bit off. And then there's the new

Get the local date instead of UTC

橙三吉。 提交于 2020-06-29 04:19:05
问题 The following script calculates me next Friday and next Sunday date. The problem : the use of .toISOString uses UTC time. I need to change with something that outputs local time. I'm very new to javascript so I can't find the right property to use instead of .toIsostring. What should I do ? function nextWeekdayDate(date, day_in_week) { var ret = new Date(date || new Date()); ret.setDate(ret.getDate() + (day_in_week - 1 - ret.getDay() + 7) % 7 + 1); return ret; } let nextFriday =

Date format issues in plot ticks with matplotlib.dates (and datestr2num)

岁酱吖の 提交于 2020-06-28 08:39:42
问题 I'm using matplotlib.dates to plot a bar chart with instances occurring on specific dates (presented as a list of strings), and using matplotlib.dates.datestr2num to display two sets of data per date (as per the top answer in Python matplotlib multiple bars). However, for dates below the 12th day of the month, the plot is interpreting the dates in MM/DD/YY format, while for dates above the 12th day of the month it is interpreting the dates as DD/MM/YY, causing the data to jump around the plot

Two-digit year in SimpleDateFormat

▼魔方 西西 提交于 2020-06-28 02:53:23
问题 Maybe this question is fool, but I didn't have found any answer that has satisfied me. I have a SimpleDataFormat like: sdf = new SimpleDateFormat("dd/MM/yyyy"); And if I try to parse a date like: 10/10/15 Then the Date result is for year 15, and not 2015. Why the parse works in this case? I was expecting a ParseException How I force the user to put year in 4 digit format? (Without String.length() please) I'm using setLenient(false) 回答1: Your date is interpreted literally. Per http://docs

Correct Date format to use for GsonBuilder Date Format

心不动则不痛 提交于 2020-06-27 16:21:23
问题 My client sends me a date in "2019-11-22T16:16:31.0065786+00:00" format. I am getting the following error: java.text.ParseException: Unparseable date: "2019-11-22T16:16:31.0065786+00:00" The date format that I am using is: new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSZ") .create(); Please let me know which format to use. 回答1: This format can be handled by DateTimeFormatter.ISO_ZONED_DATE_TIME instance of DateTimeFormatter . It is a part of Java Time package which was released