KingZ
KingZ

Reputation: 33

Exchanging Information between HTML Form and SQL Database

Happy Easter to y'all!

So my problem is essentially using SQL timestamp is causing me some issues. I have a Travel Booking website with a database made in PHPmyadmin and as mentioned two timestamp columns (one for departure time and one for arrival.) If there are times currently there for the journey they will be displayed, if not a tick box to set the current time as the timestamp, this i'm fine with.

I don't know what html form element to use to display the entirety of the SQL timestamp, both the date and time section in the html form (or how to validate any of it xD) I have tried splitting the timestamp and displaying it in both a date and time field but had no luck and was told to stick to the timestamp by my group members. Cheers

Upvotes: 0

Views: 57

Answers (1)

KingZ
KingZ

Reputation: 33

Solved the problem with some troubleshooting. The formatting difference between datetime-local and timestamp can be solved with some simple regex.

VariableName = re.sub(r"\s+", 'T', VariableName)

Swaps any whitespace characters with a T.

This is because datetime-local likes to concatenates the date and time together using a capital T. If we simulate this using the regex above we can convert the timestamp into a readable format.

Upvotes: 1

Related Questions