rbatis / fastdate

fastdate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to format DateTime?

RazgrizHsu opened this issue · comments

commented

I would like to ask if there is a way to format as a string?
like ..

let now = Local::now().format( "%Y%m%d %H%M%S%.f" );

thanks you :)

commented

Or can you point me how can I pad 6 decimal places after nano seconds,
Because when use format!( "{:29}", now )
the 2022-10-24 13:22:47.977840 will be 2022-10-24 13:22:47.97784
missing last zero

thank you

commented

Or can you point me how can I pad 6 decimal places after nano seconds, Because when use format!( "{:29}", now ) the 2022-10-24 13:22:47.977840 will be 2022-10-24 13:22:47.97784 missing last zero

thank you

This is a no time zone design。
format you can use

format!( "{}-{}-{}T{}:{}:{}", now.year,now.mon,now.day,now.hour,now.min,now.sec)
commented