Custom Script for last day from the month

Hi
I have pb with frappe.datetime or frappe.date in client script

I need the last day of month 6,
i used frappe.datetime.month_end (‘06-06-2025’)
But he gave me the last day of this month 2025-02-28
What to use to get 30-06-2025?

Thank you in advance

Hi @SanadIT:

frappe.datetime.month_end always returns the end of the current month.

Try instead

moment().month('June').endOf("month").toDate()

or

moment().month(5).endOf("month").toDate()

(*) Note that month(x) is zero-based, January is 0 , so June is 5

Hope this helps.

1 Like

No result

It’s working for me.
Can you share your code?

Above answer is correct, but if you want date in string then do just:

moment().month(5).endOf("month").format() 

Example:

image

1 Like

moment().month(5).endOf(“month”).format()

it worked

Thank you

I think the pb is not resolved with .todate()

Thank you for helps

1 Like