2011-12-06 14 views
7
D <- "06.12.1948"     # which is dd.mm.yyyy 
as.Date(D, "%d.%m.%y")   # convert to date 
[1] "2019-12-06"     # ????  

मुझे क्या याद आ रहा है?स्ट्रिंग को आज तक कनवर्ट करें, प्रारूप: "dd.mm.yyyy"

Sys.getlocale (श्रेणी = "LC_ALL") [1] "LC_COLLATE = German_Austria.1252; LC_CTYPE = German_Austria.1252; LC_MONETARY = German_Austria.1252; LC_NUMERIC = C; LC_TIME = German_Austria.1252"

उत्तर

19

प्रारूप केस-संवेदी है ("% y" अस्पष्ट और प्रणाली निर्भर है, मेरा मानना ​​है कि):

as.Date(D, "%d.%m.%Y") 
[1] "1948-12-06" 

मदद विषय ?strptime विवरण है:

‘%y’ Year without century (00-99). On input, values 00 to 68 are 
     prefixed by 20 and 69 to 99 by 19 - that is the behaviour 
     specified by the 2004 and 2008 POSIX standards, but they do 
     also say ‘it is expected that in a future version the default 
     century inferred from a 2-digit year will change’. 
+0

इस पर विस्तार करने के लिए, '"% y "' 2 अंकों वर्षों के लिए है, इसलिए इसे "19" 1948 में आप चाहते हैं '"% Y "' में पढ़ा है। –

संबंधित मुद्दे