Sign Up

Sign In

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Sorry, you do not have a permission to ask a question, You must login to ask question.

Sorry, you do not have a permission to add a post.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

How to convert a date time into into format of dd/mm/yyyy ?

How to convert a date time into into format of dd/mm/yyyy ?

If you need to convert a date-time like 2020-04-28 00:00:00 which comes for example from the backend, you can use the following JavaScript code:

<script type="text/javascript">
			function convertDate(inputDate) {
			  function change(s) { return (s < 10) ? '0' + s : s; }
			  var temp = new Date(inputDate);
			  return [change(temp.getDate()), change(temp.getMonth()+1), temp.getFullYear()].join('/');
			}
			
			var newDate = convertDate('2020-04-28 00:00:00');
			console.log(newDate); // 28/04/2020
</script>

A simple function that saves you a lot of hassle.
If you have other solutions, I invite you to post them in the comments.

Related Posts

Leave a comment

What is the capital of Egypt? ( Cairo )

How to? Ask a Question