function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Soundhariyaa MSoundhariyaa M 

convert timestamp 2021-06-12 14:46:19 to 2021-06-12 14-46-19

How to convert a timestamp in this format "2021-06-12 14:46:19" to "2021-06-12 14-46-19"..

Can anyone help me with this
THanks in advance!
Best Answer chosen by Soundhariyaa M
CharuDuttCharuDutt
Hii Soundhariyaa
Try Below Code
DateTime dt = DateTime.now();
String dateTimeStr = dt.format('yyyy/MM/dd hh-mm-ss');
system.debug('before ===> '+ dateTimeStr);
Please Mark It As Best Answer If It Helps
Thank You!

 

All Answers

Soundhariyaa MSoundhariyaa M
In apex
CharuDuttCharuDutt
Hii Soundhariyaa
Try Below Code
DateTime dt = DateTime.now();
String dateTimeStr = dt.format('yyyy/MM/dd hh-mm-ss');
system.debug('before ===> '+ dateTimeStr);
Please Mark It As Best Answer If It Helps
Thank You!

 
This was selected as the best answer