If you want the X effect on Y and random intercept of both year and month, the code would go
m1<-lmer(Y ∼ X+(1|month)+(1|year),data = dataset,REML="TRUE")
If you want random intercepts of month and year and random slopes of X for month and year, the code would go
m2<-lmer(Y ∼ X+(X|month)+(X|year),data = dataset,REML="TRUE")
However, m1 and m2 give the code assuming year and month are crossed random effects and I'm not sure whether months should actually be nested within years, in which case the codes would go
m3<-lmer(Y ∼ X+(1|year:month),data = dataset,REML="TRUE")
m4<-lmer(Y ∼ X+(X|year:month),data = dataset,REML="TRUE")
I think the crossed vs. nested might depend on the exact nature of your data. My intuition is that if you gathered your data from same individuals across years, then your random effects would be nested. However, if the actual observational units were different, I think they would be crossed, but I admit I'm not sure. Here is a good explanation of crossed vs. nested random effects.
I've also seen it recommended in a roughly comparable case that month would be entered as a fixed effect, which would go
m5<-lmer(Y ∼ X+factor(month)+(X|year),data = dataset,REML="TRUE")
but in the example case there were only 5 months so this advice may not apply as you have 12.