0

I was able to insert data to my sqlserver database using this:

date("Y-m-d H:i:s", strtotime($promostart));

So the value on my database is: 2021-08-10 23:59:00.000

I tried echoing the value from my database directly to my input field like this: <input type="datetime-local" id="dateStart" name="dateStart" value="<?php echo $row[DurationStart];">

But the input field does not show both time and date specified in the value. and shows up like this: enter image description here

What should i do to be able to output/display it to my datetime-local input field?

Any clue or guide is greatly appreciated. Thanks!

2
  • 1
    Select it and then echo it? It's a bit unclear where you're stuck, and the specifics of how you might do it could depend on the overall way your application is implemented (and the relationship between the data layer and the UI). We don't have any of that context. Please see How to Ask and then clarify your post. Thanks. Commented Aug 17, 2021 at 16:22
  • Thank you for the heads up. I added more information to my question, sorry about that. I already tried echoing the data into the datetime-local's value="" but the field still shows the placeholder instead of the one i echoed. Commented Aug 17, 2021 at 16:39

1 Answer 1

1

I was able to set the datetime-local input value using date() function:

$dateStart = $row['DurationStart'];
date("Y-m-d\TH:i:s", strtotime($dateStart));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.