NSDateFormatter issue with date format in iOS 8 - nsdate

I have an NSDateFormatter which I use to format an NSDate into a string. The following format does not work: ddMMyyyy_hhmmss_SSS. When I try to format an NSDate I get the following output: 18092014_08:49:03,638, which has a colon and a comma I didn't specify in the format. Note that in iOS 7 I never had this kind of problem.
This is the code I'm using:
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat: #"ddMMyyyy_hhmmss_SSS"];
NSString *dateString = [dateFormat stringFromDate:exportDate];

iOS8 have serious problem with time format imo. I've just resolved a bug on my application (that i've never had with iOS7) going to settings -> general -> date time -> time format, switching it from 24 to 12 and then back to 24 and all started working again.
Try to make my same procedure, maybe it work also for you!

I got problems with NSDateFormatter in iOS 8 too, and had to build a fix version for an app. You could read this. It basically takes to overwrite the default locale:
formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:#"en_US_POSIX"];
But it's best not to use it for formats you want to show to the user. Hope it helps!

Related

How to get system long date using mfc?

I need to get system current long date using MFC. My requirement is I need to get the system long date without format. For example: In my system if the date sets in "dd/mm/yyyy" format then I need to get in same format.
Suppose in my system if I change the format as "yyyy/mm/dd" then I need to get the output as what ever I sets in my system.
I found DATE_SHORTDATE is getting the date as it is how the system displays, if I use DATE_LONGDATE it will always gets the system date in 'dd/mm/yyyy' format
CString strValue;
SYSTEMTIME st;
CTime time = CTime::GetCurrentTime();
time.GetAsSystemTime(st);
GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, strValue.GetBufferSetLength(50), 50);
strValue.ReleaseBuffer();
Kindly assist me on this requirement.
Your code returns the correct value, however using 'mm' string is not supported by some of the locales in LongDate format.
On my Windows 10 1903, English-US locale, the control panel overrides the 'mm' value to 'MM'.
,
More reference regarding LongDatePattern:
https://learn.microsoft.com/en-us/dotnet/api/system.globalization.datetimeformatinfo.longdatepattern?view=netframework-4.8

momentjs endOf('month') does not deliver last day of month

When I invoke the following code
moment('2020-01-01T00:00:00Z').endOf('month').utc().format()
I get the result
'2020-01-01T07:59:59Z'
when I would have expected to see
'2020-01-31T23:59:59Z'
Is this a bug or am I not using the API correctly?
I think the problem is you used endOf before you convert the Date in UTC.
You pass this Date : 2020-01-01T00:00:00Z but the browser understand it with your timezone so the "real date" is 2019-12-31T15:00:00Z.
So you must convert it to UTC first and then proceed your change/call/etc.
So, I tried that and it worked ! Tell me if the problem persist.
moment('2020-01-01T00:00:00Z').utc().endOf('month').format()

querysting binding error when using ServiceStack version 4.0.34 and OrmLiteCacheClient

We're getting an "unable to bind to request" when calling a service with the following querystring:
/SomeService?playerid=59326&fromdate=4-1-2014&todate=12-11-2014
We have been using this querysting format for awhile now.
The problem is some either a change in 4.0.34, or something in the OrmLightCacheClient, which we had turned off for awhile and only just recently turned it back on.
If I change the dates to following format, it seems to work.
/SomeService?playerid=59326&fromdate=2014-4-1&todate=2014-12-31.
We can roll with the changed querystring date format for now, but wanted to report the error.
When supplying a date only (i.e. doesn't include a time) it should be unambiguously defined using the YYYY-MM-DD format.

String to Date Time Conversion in windows phone app

I am new to windows app development. I need to convert Date and Time available in String Format to dd/mm/yyyy and hh:mm format so that I can use it in setting the reminder.
thanks in advance......
I think you mean DateTime.Parse(string)
You can use like this
string ss=DateTime.Now.ToLongDateString();
For additional Information---
http://msdn.microsoft.com/en-us/library/system.datetime.tolongdatestring(v=vs.110).aspx

Creating an NSDate which is "Tomorrow at 7:00AM"

How can I create an NSDate which is set to tomorrow at 7:00AM?
I think this should help you:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/DatesAndTimes/Articles/dtCalendars.html
See also: How do i add 1 day to a NSDate?

Resources