날짜를 문자열로 반환하려고했지만 반환 된 시간의 처음 0을 제거하려고합니다.Ruby/Rails - DateTime 구문 분석
t = Time.new
current_date = Time.local(t.year, t.month, t.day, t.hour, t.min/30*30)
time_str = current_date.strftime("%I.%M+%p").downcase
puts time_str
Outputs:
03.00+pm
Expected output:
3.00+pm # need to remove the last zero from the hour(s)
반환되는 문자열이''3.00 + pm "'이므로 끝에 'strip!'을 추가해야했습니다. 고마워! – fuzz
당신은 오신 것을 환영합니다 .. 미래의 방문자의 도움을 받아 대답으로 표시하는 것을 잊지 마세요. –