Splunk Search

time format change

VijaySrrie
Builder

Hi,

I have a field (Lastsynctime) which outputs time in below format

2021-10-02 09:06:18.173

I want to change the time format like 

"%d/%m/%Y %H:%M:%S"

I tried with strf command, which is not working

| eval SyncTime=strftime(Lastsynctime,"%d/%m/%Y %H:%M:%S")
Labels (4)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @VijaySrrie,

the strftime option works with epochtime dates, so you have to convert your date from your format to epochtime and then from epochtime in your format, something like this:

| eval SyncTime=strftime(strptime(Lastsynctime,"%Y-%m-%d %H:$M:$S.$3N"),"%d/%m/%Y %H:%M:%S")

Ciao.

Giuseppe

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi @VijaySrrie,

the strftime option works with epochtime dates, so you have to convert your date from your format to epochtime and then from epochtime in your format, something like this:

| eval SyncTime=strftime(strptime(Lastsynctime,"%Y-%m-%d %H:$M:$S.$3N"),"%d/%m/%Y %H:%M:%S")

Ciao.

Giuseppe

Get Updates on the Splunk Community!

Prove Your Splunk Prowess at .conf25—No Prereqs Required!

Your Next Big Security Credential: No Prerequisites Needed We know you’ve got the skills, and now, earning the ...

Splunk Observability Cloud's AI Assistant in Action Series: Observability as Code

This is the sixth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...

Splunk Answers Content Calendar, July Edition I

Hello Community! Welcome to another month of Community Content Calendar series! For the month of July, we will ...