Formatting NSDate into particular styles for both year, month, day, and hour, minute, seconds

this is what i used: NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@”yyyy-MM-dd”]; NSDateFormatter *timeFormat = [[NSDateFormatter alloc] init]; [timeFormat setDateFormat:@”HH:mm:ss”]; NSDate *now = [[NSDate alloc] init]; NSString *theDate = [dateFormat stringFromDate:now]; NSString *theTime = [timeFormat stringFromDate:now]; NSLog(@”\n” “theDate: |%@| \n” “theTime: |%@| \n” , theDate, theTime); [dateFormat release]; [timeFormat release]; [now release];

What are the “standard unambiguous date” formats for string-to-date conversion in R?

This is documented behavior. From ?as.Date: format: A character string. If not specified, it will try ‘”%Y-%m-%d”‘ then ‘”%Y/%m/%d”‘ on the first non-‘NA’ element, and give an error if neither works. as.Date(“01 Jan 2000”) yields an error because the format isn’t one of the two listed above. as.Date(“01/01/2000”) yields an incorrect answer because the date … Read more

`uuuu` versus `yyyy` in `DateTimeFormatter` formatting pattern codes in Java?

Within the scope of java.time-package, we can say: It is safer to use “u” instead of “y” because DateTimeFormatter will otherwise insist on having an era in combination with “y” (= year-of-era). So using “u” would avoid some possible unexpected exceptions in strict formatting/parsing. See also this SO-post. Another minor thing which is improved by … Read more

How to format time since xxx e.g. “4 minutes ago” similar to Stack Exchange sites

function timeSince(date) { var seconds = Math.floor((new Date() – date) / 1000); var interval = seconds / 31536000; if (interval > 1) { return Math.floor(interval) + ” years”; } interval = seconds / 2592000; if (interval > 1) { return Math.floor(interval) + ” months”; } interval = seconds / 86400; if (interval > 1) { … Read more