Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to implement output the current time #178

Open
amiaogo opened this issue May 19, 2023 · 1 comment
Open

How to implement output the current time #178

amiaogo opened this issue May 19, 2023 · 1 comment

Comments

@amiaogo
Copy link

amiaogo commented May 19, 2023

For example, the expression:time.Now().Format("2006-01-02 15:04:05"),Is it supported?

@amiaogo amiaogo changed the title How to implement output the current system time How to implement output the current time May 19, 2023
@s6816112
Copy link

s6816112 commented Jun 26, 2023

    functions := map[string]govaluate.ExpressionFunction {
	"timeFormat": func(args ...interface{}) (interface{}, error) {
		return time.Now().Format("2006-01-02 15:04:05"), nil
	},
}
expString := "timeFormat()"
expression, _ := govaluate.NewEvaluableExpressionWithFunctions(expString, functions)

result, _ := expression.Evaluate(nil)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants