liu skywalker wrote in post #1011661: > в 2011ǯ07·î19Æü 21:42, Annie smith ¼ÌÆ»: >> Hi All, >> >> Do you know how to change date format from Y/m/d to Y-m-d in ruby? >> >> Thanks! >> > def convert!(time) > time=times.split("/").join("-") > end > convert!("2011/11/11) Aside 1: it's unconventional to put an exclamation mark at the end of a method name, if the method does absolutely nothing dangerous, nor does it modify the receiver. Aside 2: no need to assign the result. Also, 'times' is not known. Here's a corrected version: def convert(time) time.split("/").join("-") end Here's an alternative one: def convert(time) time.gsub(%r{/}, '-') end