date

why the result of my date object always several hours behind the actual string that I want to convert? [duplicate]

こ雲淡風輕ζ 提交于 2021-01-29 07:08:58
问题 This question already has answers here : NSDate() or Date() shows the wrong time (2 answers) NSDate Format outputting wrong date (5 answers) NSDateFormatter return wrong date + Swift (4 answers) Closed 2 years ago . I am a junior iOS developer. and now I have problem when converting string to date object. I don't know why the result (date object) always 7 hour behind the actual string I input. currently I am in Indonesia (GMT + 7), I don't know, but maybe it is related to the place where I

MongoDB date in timezone

巧了我就是萌 提交于 2021-01-29 07:02:20
问题 Is there a way to store Dates in local timezone and not in UTC ? This is my schema : var WhispSchema = new mongoose.Schema({ text : String, pos : {latitude: Number, longitude: Number}, distance : {type : Number, default : 0}, created_by : {type : Schema.Types.ObjectId, ref : "UserSchema"}, upvote : {type : Number, default : 0}, downvote : {type : Number, default : 0} }); WhispSchema.plugin(timestamps, { createdAt: 'created_at', updatedAt: 'updated_at' }); But the field "created_at" and

Convert string to date using moment.js [duplicate]

一世执手 提交于 2021-01-29 06:45:28
问题 This question already has answers here : Moment.js - how do I build moment from date and time string? (2 answers) Closed 3 years ago . This my model.ts export class Feature2 { requestRouteTemplate: string; requestMethod: string; numberCount: number; requestDate: date; constructor(values: Object = {}) { Object.assign(this, values); } } This is component.ts this.datas2 = [ { 'requestRouteTemplate': 'api/Tasks', 'requestMethod': 'POST', 'numberCount': 6, 'requestDate': '07/01/2017', }, {

Convert string of format “19-07-2018 08:10:24” in date and time both different string format

梦想的初衷 提交于 2021-01-29 06:13:21
问题 I want to Convert string of format "19-07-2018 08:10:24" in date time format. If the date is today then it should be "02:12 am". If the date is of yesterday then it should be like "Yesterday". Otherwise it should be in "DD/MM/yy" format. Currently I am having the time and date in string formate. I want the final answer in string type. If the answer is "DD/MM/YY", then it should be in string format. 回答1: Use the Calendar date functions: func format(date: Date) -> String { let calendar =

Why does Date.parse give incorrect results?

旧巷老猫 提交于 2021-01-29 06:03:22
问题 Case One: new Date(Date.parse("Jul 8, 2005")); Output: Fri Jul 08 2005 00:00:00 GMT-0700 (PST) Case Two: new Date(Date.parse("2005-07-08")); Output: Thu Jul 07 2005 17:00:00 GMT-0700 (PST) Why is the second parse incorrect? 回答1: Until the 5th edition spec came out, the Date.parse method was completely implementation dependent ( new Date(string) is equivalent to Date.parse(string) except the latter returns a number rather than a Date ). In the 5th edition spec the requirement was added to

Batch file datetime windows settings

梦想与她 提交于 2021-01-29 06:02:40
问题 Recently my windows was backed with image restore software to previous version, so I had to install everything from scratch. What really stresses me is that script that had worked before now doesn't. It's related to dates and datetime. My colleague tried to run .bat file and he was able to get appropriate date format. I tried to copy all the windows 10 date settings and still it doesn't work. Any ideas how to solve this? My output is: C:\Software\scripts>for /F "usebackq tokens=1,2 delims=="

How to process yyyy-mm and yyyy in java8 using DateTimeFormatter

社会主义新天地 提交于 2021-01-29 05:48:26
问题 Am using SimpleDateFormat to format or validate the dates, but I would like to make it thread-safe by using java 8 DateTimeFormatter. I am having trouble to achieve some requirement. My application will accept only three types of formats. "yyyy-MM-dd", "yyyy-MM", "yyyy" Existing Code gives me desired output: /*simple date format to process yyyy-MM-dd format SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd") /*simple date format to process yyyy-MM format SimpleDateFormat

R dates as column names containing duplicate values (need to retain original date)

时光毁灭记忆、已成空白 提交于 2021-01-29 05:31:56
问题 I have a dataset I'm trying to tidy up. I read in the file with read.xlsx, contained in the header is date values that I need to retain their values even when duplicated when I gather/spread the data. The data set looks like the below. The dates from excel read in as numbers (which is fine) the issue is that there can be duplicate dates (e.g. 43693) , which I need to keep their original values. Date 43693 43686 43686 43714 43693 1 Contract 111 222 333 444 555 2 Org1 NR NB NR NB P 3 Org2 P P P

How to match dates in 2 data frames in R, then sum specific range of values up to that date?

六眼飞鱼酱① 提交于 2021-01-29 04:35:33
问题 I have two data frames: rainfall data collected daily and nitrate concentrations of water samples collected irregularly, approximately once a month. I would like to create a vector of values for each nitrate concentration that is the sum of the previous 5 days' rainfall. Basically, I need to match the nitrate date with the rain date, sum the previous 5 days' rainfall, then print the sum with the nitrate data. I think I need to either make a function , a for loop, or use tapply to do this, but

R Date origin for formatting

拟墨画扇 提交于 2021-01-29 04:28:27
问题 I read this example about using the origin to set the date start time. I am reading in from csv where the dates are the number of days and read in as factors. Example: $ admin_date : Factor w/ 318 levels "37362","37735" I would like to convert to date formats to measure number of days and months between events. But when I try all of the different origin such as: df$admin_date_new <- as.numeric(df$admin_date) df$admin_date_new <- as.Date(df$admin_date, origin="1900/01/01") I get the following: