

Convert Variables and Strings to Date-Time Format
source link: https://www.codesd.com/item/convert-variables-and-strings-to-date-time-format.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Convert Variables and Strings to Date-Time Format
I currently have the following variables and formatted data:
- Scheduling_StartDate_Month = 10
- Scheduling_StartDate_Day = 1
- Scheduling_StartDate_Year = 2012
- Scheduling_StartTime = 3:00 PM
I need to combine them into one variable 'schedstart' of type 'datetime' to insert into my database, and I'm completely lost. I have tried to research the issues, and found suggestions to use mktime() or sttodate() but I couldn't find any reliable syntax guidelines.
How do I combine those variables using PHP?
You can consider concatenating in a proper format on the PHP:
<?php
$dateString = $Scheduling_StartDate_Month."/".$Scheduling_StartDate_Day."/".$Scheduling_StartDate_Year." ".$Scheduling_StartTime;
$result = mysql_query("SELECT STR_TO_DATE('".$dateString."', '%m/%d/%Y %h:%i %p')");
?>
Related Articles
How to analyze and convert DateTime to RFC 822 date-time format?
CAST () or CONVERT () do not change the date-time format to a string in SQL Server 2008
Try to convert a string to date-time format in vb.net 2005
How to convert two different strings to date format and find their differences in JSP / JAVA
Convert long date strings in Excel to a sortable date / time format
How to convert a date field to date-time format? SQL 2008
Convert to date-time format for pandas?
Merge two columns into a single column and format the content to form a specific date-time format in Hive?
How to convert nanoseconds of uptime to a readable date time format
How to update / change the system date time format in the regional and language options of the control panel using the code?
How can I change the date time formats in Perl?
If I have a date time format, do I need to display a single time?
Implement LINQ expressions to SQL for a database with a custom date / time format
Change the default date time format on a single database in SQL Server
Recommend
-
26
Format a time or date [complete guide] yourbasic.org/golang Basic example Go doesn’t use yyyy-mm-dd layout to format a t...
-
8
Format Strings Tips and Tricksmikeash.com: just this guy, you know? Friday Q&A 2009-07-17: Format Strings Tips and Tricks by Mike Ash Greeti...
-
11
How to format Date & Time in FlutterDatetime formatting made simple using this packagePhoto by
-
14
How to Convert Time in 12-Hour Format to 24-Hour Format With Programming By Yuvraj Chandra Published 7 hours ago Want 4:30 PM t...
-
15
How to Convert a Date from yyyy-mm-dd to dd-mm-yyyy Format in PHP 4697 views 1 year ago PHP Use the...
-
3
FORMAT is a convenient but expensive SQL Server function - Part 1 By: Aaron Bertrand | Updated: 2022-02-16 |
-
9
[PHP] Convert a date from french month name to another format · GitHub [PHP] Convert a date from french month name to another format <?php /**...
-
13
Javascript Convert Date and Time Example 158 views 5 months ago Javascript In this article, we will share with y...
-
8
Kapil Kumar March 3, 2022 Less than a 1 minute read...
-
6
How to Convert UTC Date Time to Local Date Time in JavaScript 8576 views 2 years ago Javascript Use the...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK