I am sending today date to server but server shows yesterday date what's wrong with me? here i am using the code for getting date and sending date .
NSString *dateValue = borntext.text;
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"MM/dd/yyyy"];
NSDate *date = [formatter dateFromString:dateValue];
long dateInMillis = [date timeIntervalSince1970];
NSString *actDate = [NSString stringWithFormat:@"Date(%@)/",born];
NSString *nDate = [[[[actDate componentsSeparatedByString:@"("] objectAtIndex:1] componentsSeparatedByString:@")"] objectAtIndex:0];
NSDate *date = [NSDate dateWithTimeIntervalSince1970:([nDate doubleValue])];
NSDateFormatter *dtfrm = [[NSDateFormatter alloc] init];
[dtfrm setDateFormat:@"MM/dd/yyyy "];
nDate = [dtfrm stringFromDate:date];
her i am converting milliseconds to date from server and sending date is convert to milli seconds.so please help me.thanks in advance
You'll need to agree to use the same timezone, and GMT/UTC is generally accepted as the best common timezone.
Therefore set the NSDateFormatter
timezone with:
formatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
The server "API" should document this; else I would raise it as a bug with the providers.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments