weekday

Get next date from weekday in JavaScript

与世无争的帅哥 提交于 2019-11-27 06:39:31
问题 How can one return the next date of a given weekday (it could be either a number 0-6 or names Sunday-Saturday). Example, if today, on Friday 16-Oct-2009 I passed in: Friday , it would return today's date 16-Oct-2009 Saturday returns 17-Oct-2009 Thursday returns 22-Oct-2009 回答1: Just adding 7 doesn't solve the problem. The below function will give you the next day of the week. function nextDay(x){ var now = new Date(); now.setDate(now.getDate() + (x+(7-now.getDay())) % 7); return now; } 回答2:

Objective C - How can i get the weekday from NSDate?

人走茶凉 提交于 2019-11-27 05:55:06
问题 I need to be able to get the weekday from nsdate, i have the following code and it always return 1. I tried to change the month, i tried everything from 1 to 12 but the result of the week day is always 1. NSDate *date2 = [[NSDate alloc] initWithString:[NSString stringWithFormat:@"%d-%d-%d", 2010, 6, 1]]; unsigned units2 = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit; NSCalendar *calendar2 = [[NSCalendar alloc] initWithCalendarIdentifier

How to find nearest day of week in php?

↘锁芯ラ 提交于 2019-11-27 03:23:10
问题 How to find a speciefic nearest day of the week in PHP if initially I have a date string like: 07.05.2010 ? For example, I want to find the nearest Sunday (or any day of the week). How can I implement this? Thanks 回答1: This should do: echo date('d.m.Y', strtotime('next Sunday', strtotime('07.05.2010'))); 回答2: Just in case you wanted the nearest day rather than the next one, here is a way to do that. $target = "Sunday"; $date = "07.05.2010"; // Old-school DateTime::createFromFormat list($dom,

Trigger notification weekly Swift 3

冷暖自知 提交于 2019-11-26 23:06:59
I am trying to make a schedule, in which I need to remember all the weeks I have class such as Monday at certain time. The problem is that if I assign weekday = 1 (Sunday) when I print the variable triggerWeekly it tells me that weekday = 2, so by performing the tests I do not receive such notification. I need to know why this happens let weekday = 1 //Sunday 19 Mar let calendar = NSCalendar.current var date = DateComponents() date.weekday = weekday date.hour = 1 date.minute = 5 let ultimateDate = calendar.date(from: date) let triggerWeekly = Calendar.current.dateComponents([.weekday, .hour,

Joda Time: First day of week?

风格不统一 提交于 2019-11-26 22:19:28
How do you get the first day of week given a Locale using Joda-Time ? Point: Most countries use the international standard Monday as first day of week (!). A bunch others use Sunday (notably USA). Others apparently Saturday. Some apparently Wednesday?! Wikipedia "Seven-day week"#Week_number JodaStephen Joda-Time uses the ISO standard Monday to Sunday week. It does not have the ability to obtain the first day of week, nor to return the day of week index based on any day other than the standard Monday. Finally, weeks are always calculated wrt ISO rules. There's no reason you can't make use of

How to get day from specified date in android

放肆的年华 提交于 2019-11-26 22:05:54
问题 Suppose my date is 02-01-2013 and it is stored in a variable like: String strDate = "02-01-2013"; then how should I get the day of this date (i.e TUESDAY)? 回答1: Use Calendar class from java api. Calendar calendar = new GregorianCalendar(2008, 01, 01); // Note that Month value is 0-based. e.g., 0 for January. int reslut = calendar.get(Calendar.DAY_OF_WEEK); switch (result) { case Calendar.MONDAY: System.out.println("It's Monday !"); break; } You could also use SimpleDateFormater and Date for

Joda Time: First day of week?

本小妞迷上赌 提交于 2019-11-26 08:19:59
问题 How do you get the first day of week given a Locale using Joda-Time? Point: Most countries use the international standard Monday as first day of week (!). A bunch others use Sunday (notably USA). Others apparently Saturday. Some apparently Wednesday?! Wikipedia \"Seven-day week\"#Week_number 回答1: Joda-Time uses the ISO standard Monday to Sunday week. It does not have the ability to obtain the first day of week, nor to return the day of week index based on any day other than the standard

Trigger notification weekly Swift 3

我的梦境 提交于 2019-11-26 07:49:23
问题 I am trying to make a schedule, in which I need to remember all the weeks I have class such as Monday at certain time. The problem is that if I assign weekday = 1 (Sunday) when I print the variable triggerWeekly it tells me that weekday = 2, so by performing the tests I do not receive such notification. I need to know why this happens let weekday = 1 //Sunday 19 Mar let calendar = NSCalendar.current var date = DateComponents() date.weekday = weekday date.hour = 1 date.minute = 5 let

How do I get the day of week given a date?

北慕城南 提交于 2019-11-25 23:33:55
问题 I want to find out the following: given a date ( datetime object), what is the corresponding day of the week? For instance, Sunday is the first day, Monday: second day.. and so on And then if the input is something like today\'s date. Example >>> today = datetime.datetime(2017, 10, 20) >>> today.get_weekday() # what I look for The output is maybe 6 (since it\'s Friday) 回答1: Use weekday() (docs): >>> import datetime >>> datetime.datetime.today() datetime.datetime(2012, 3, 23, 23, 24, 55,