Convert “minutes since midnight” to time (convert to NSDate?)



I am getting some open/closed times as integers since midnight. For example:


"1140" = 19:00 (or 7 pm if you will) or;
"570" = 9:30 (or 9.30 am)


I can easily get the time in European format, just by doing doing a simple calculation and formatting:


[NSString stringWithFormat:@"%d:00", (T / 60)]

However, this doesn't work for half hours, such as "570 minutes since midnight". Also, I run into problems if I want to include a bit of localization, because some people may prefer AM/PM times.


Does NSDate include a method for easily implementing times using the above? Or can anyon


Related to : Convert “minutes since midnight” to time (convert to NSDate?)
iPhone: How to convert “yyyyMMddThhmmss” format string to NSDate?
Mobile Programming

I have a string like "20121124T103000" and I want to convert this to NSDate.


I tried converting it with dateFormatter date format "yyyyMMddThhmmss" but it gives output as 2001-01-01 00:00:00 +0000 which is incorrect.


What is the way we can convert this string to NSDate?


Here is my code:


NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyyMMddThhmmss"];
NSLog(@"%@",[dateFormat dateFromString:@"20121124T103000"]);

Any help is appreciated.


jquery function to convert datetime, split date time “2010-10-18 10:06” to return “18/10/2010” and “10:06”
Mobile Programming

Hi I was wondering if there is any jquery function around which can take this dateTime "2010-10-18 10:06" and convert and split it returning "2010/10/18" and "10:06".


It would be also nice if the same function could either receive "2010-10-18 10:06" or "2010-10-18" only and return as mentioned above, or different formats besides "2010/10/18" like 18-10-2010" or and 18th of October 2010, giving the option but not that important, just curious about jQuery power dealing with dates.


Thanks.


Convert “current time” to “time in minutes since 00:00” calculation help
Mobile Programming

I haven't used NSDate that much, so I'd like some help with a calculation I am doing.


I have an integer that has my store's closing hour in minutes since midnight. Basically, my store closes at 5.00PM, which gives me the integer 1020.


So right now it's 10.45PM or 22.45. Integer since 00:00 is 1365, and from this I can say


if (storeHour < currentTime) {
// closed!
}

However, I don't know how I get from "22.45" that I have from NSDate to converting it to an integer representing time since 00:00. Is there something in NSDate that can help me with that?


Thx


Convert integer minutes into String “hh:mm”
Mobile Programming

I need to convert minutes (defined as Integer) into the following String format "hh:mm" assuming that the startTime is "00:00". The below-given code is what I have so far, but it does not work properly. Also it does not take into account that the newTime should be shifted in accordance to startTime. Is there any other solution?


String startTime = "00:00";
int minutes = 120;
double time = minutes/60;
String timeS = Double.toString(time);
String[] hourMin = timeS.split(".");
String h = hourMin[0];
String m = hourMin[1];
String newTime = "";
newTime.concat(h+":"+m);<
Convert “minutes since midnight” to time (convert to NSDate?)
Mobile Programming

I am getting some open/closed times as integers since midnight. For example:


"1140" = 19:00 (or 7 pm if you will) or;
"570" = 9:30 (or 9.30 am)


I can easily get the time in European format, just by doing doing a simple calculation and formatting:


[NSString stringWithFormat:@"%d:00", (T / 60)]

However, this doesn't work for half hours, such as "570 minutes since midnight". Also, I run into problems if I want to include a bit of localization, because some people may prefer AM/PM times.


Does NSDate include a method for easily implementing times using the above? Or can anyon

How do I convert a string that contains “am/pm” to an NSDate when the user's device is set to 24-Hour Time in iOS?
Mobile Programming

I need to convert an NSString to an NSDate, but the following code only works as long as the user's device isn't set to 24-Hour time.


NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
[formatter setDateFormat:@"MM/dd/yyyy hh:mm:ss a"];
NSString *aTime = @"2/11/2013 12:00:00 AM";
NSDate *aDate = [formatter dateFromString:aTime];

However, aDate returns null when the device is in 24-Hour time. Any help?



Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .