How to get current date in server script

Hello,

I have written one server script and i want there current date so how i can get it??..we cant import in server script right ?

I am getting error…
Screenshot from 2024-02-21 12-57-45

Hi @pm23:

Use frappe.utils.getdate()
All frappe.utils functions are allowed.

Check this useful cheatsheet:

Hope this helps.

import package does not work on the server script doctype.

Hello @avc ,

It worked for me.

Thanks

Format the date and time accordingly.

currentTime = frappe.db.sql(“”"
SELECT DATE_FORMAT(NOW(), ‘%Y-%m-%d %H:%i:%s’)
“”", as_dict=False)[0][0]