date

Dateformatter issue in swift

青春壹個敷衍的年華 提交于 2021-02-19 09:05:19
问题 My API sending me date string in UTC like 2/20/2016 11:45 AM. For displaying date in my timezone, I am converting date from UTC to Local time zone like below code let sourceDateString = "12/20/2016 11:45 AM" let formatter = DateFormatter() formatter.dateFormat = "MM/dd/yyyy hh:mm a" formatter.timeZone = TimeZone(identifier: "UTC") let date = formatter.date(from: sourceDateString) print(date) formatter.timeZone = NSTimeZone.local formatter.dateFormat = "MMM dd,yyyy hh:mm a" let strDate =

Dateformatter issue in swift

让人想犯罪 __ 提交于 2021-02-19 09:03:51
问题 My API sending me date string in UTC like 2/20/2016 11:45 AM. For displaying date in my timezone, I am converting date from UTC to Local time zone like below code let sourceDateString = "12/20/2016 11:45 AM" let formatter = DateFormatter() formatter.dateFormat = "MM/dd/yyyy hh:mm a" formatter.timeZone = TimeZone(identifier: "UTC") let date = formatter.date(from: sourceDateString) print(date) formatter.timeZone = NSTimeZone.local formatter.dateFormat = "MMM dd,yyyy hh:mm a" let strDate =

MomentJs Format One Day Behind

纵然是瞬间 提交于 2021-02-19 08:45:17
问题 I have seen a question that is similar to mine (Moment.js sets dates to 1 day behind) but I can't seem to apply it. Essentially, my date gets parsed like this: var date = moment("2019-05-27T00:00:00Z"); // date is the 27th When I format it to get the day, expecting the 27th, I instead receive the 26th! date.format("DD") Does anyone know why this might be happening and how to correct it? http://jsfiddle.net/rmdxj26e/ 回答1: You must use moment.utc(), the Moment documentation says: By default,

Formatting X axis with dates format Matplotlib

佐手、 提交于 2021-02-19 08:35:08
问题 I have written code which plots the past seven day stock value for a user-determined stock market over time. The problem I have is that I want to format the x axis in a YYMMDD format. I also don't understand what 2.014041e7 means at the end of the x axis. Values for x are: 20140421.0, 20140417.0, 20140416.0, 20140415.0, 20140414.0, 20140411.0, 20140410.0 Values for y are: 531.17, 524.94, 519.01, 517.96, 521.68, 519.61, 523.48 My code is as follows: mini = min(y) maxi = max(y) minimum = mini -

Format date within an echo

…衆ロ難τιáo~ 提交于 2021-02-19 08:21:33
问题 I'm trying to format a MySQL formatted date (YYYY-MM-DD) and wish to display the month and year, "September 2012" for example. My code: <?php echo htmlspecialchars($row["date"], ENT_QUOTES, "UTF-8"); ?> Does anyone know how I can accomplish this? 回答1: You can use DateTime to format your date how you'd like: $date = DateTime::createFromFormat('Y-m-d', $row["date"]); echo htmlspecialchars($date->format('F Y'), ENT_QUOTES, "UTF-8"); So with a date like this: $row['date'] = '2012-09-25'; This

Convert YYYY-MM-DD to YYYY-YY Qx in R

て烟熏妆下的殇ゞ 提交于 2021-02-19 07:39:20
问题 I'm trying to plot data by quarter then display in ggplot. Dates in dataset are of the format YYYY-MM-DD, and I want the ggplot x-axis to display the financial year like YYYY-YY Qx. The financial year starts July 1. Data is in long format. This is where I've got to: Data set named: TOX TREE_ID PM_Date variable value 1: 2013000584 2013-04-02 elm 0 2: 2013000498 2013-06-11 elm 1 3: 2013000123 2013-09-03 maple 0 4: 2013000642 2014-02-15 maple 0 5: 2013000778 2016-07-08 maple 1 PM_Dateq <- as

How to find difference between two dates in years months and days in Java? [duplicate]

亡梦爱人 提交于 2021-02-19 06:19:06
问题 This question already has answers here : Calculating the difference between two Java date instances (44 answers) How to find the duration of difference between two dates in java? (16 answers) Java method to find difference between 2 date objects in years, months and days (7 answers) Closed 1 year ago . Suppose I have : Employee model which has startDate as its property variable and Promotion model has promotionDate . I want to find out for how long employee has worked until his promotion for

How to find difference between two dates in years months and days in Java? [duplicate]

本小妞迷上赌 提交于 2021-02-19 06:19:06
问题 This question already has answers here : Calculating the difference between two Java date instances (44 answers) How to find the duration of difference between two dates in java? (16 answers) Java method to find difference between 2 date objects in years, months and days (7 answers) Closed 1 year ago . Suppose I have : Employee model which has startDate as its property variable and Promotion model has promotionDate . I want to find out for how long employee has worked until his promotion for

How do I remove rows based on a range of dates given by values in 2 columns?

匆匆过客 提交于 2021-02-19 05:39:26
问题 I have a data set that includes a range of dates and need to fill in the missing dates in new rows. df1 is an example of the data I am working with and df2 is an example of what I've managed to achieve (where I'm stuck). df3 is where I would like to end up! df1 ID Date DateStart DateEnd 1 2/11/2021 2/11/2021 2/17/2021 1 2/19/2021 2/19/2021 2/21/2021 2 1/15/2021 1/15/2021 1/20/2021 2 1/22/2021 1/22/2021 1/23/2021 This is where I am with this. The NAs aren't an issue because I intend to drop

Python: Numpy and Pandas Transforming timestamp/data into one-hot-encoding

China☆狼群 提交于 2021-02-19 05:20:52
问题 I have a column of a dataframe that is like this time 0 2017-03-01 15:30:00 1 2017-03-01 16:00:00 2 2017-03-01 16:30:00 3 2017-03-01 17:00:00 4 2017-03-01 17:30:00 5 2017-03-01 18:00:00 6 2017-03-01 18:30:00 7 2017-03-01 19:00:00 8 2017-03-01 19:30:00 9 2017-03-01 20:00:00 10 2017-03-01 20:30:00 11 2017-03-01 21:00:00 12 2017-03-01 21:30:00 13 2017-03-01 22:00:00 . . . I want to "encode" the time of the day. I want to do this by firsly assigning each half an-hour a integer number. Starting