c# - Generate Date Time offset -


i have datetimeoffset input param. need create other datetimeoffset param month 2 month less input:

//datetimeoffset  input; datetimeoffset modified = new datetimeoffset(input.year, input.month - 2, input.day, input.hour, input.minute, input.second, input.millisecond, input.offset);  exception   

year, month, , day parameters describe un-representable datetime.

what wrong? - month 4. s0 4-2 = 2 valid thanks

i think month red herring, it's more day above 28 means trying create date 30th feb (which doesn't exist!).

use addmonths method instead

datetimeoffset modified = input.addmonths(-2); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -