6

Convert Variables and Strings to Date-Time Format

 2 years ago
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.
neoserver,ios ssh client

Convert Variables and Strings to Date-Time Format

advertisements

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?

How do I convert a DateTime structure to its equivalent RFC 822 date-time formatted string representation and parse this string representation back to a DateTime structure in .NET? The RFC-822 date-time format is used in a number of specifications su

CAST () or CONVERT () do not change the date-time format to a string in SQL Server 2008

I have a column which is of datetime type. I want to separate date and time for which i used left() & right() enclosed by cast() or convert() like below : Select BATCH, LEFT( CAST(S_DATE AS VARCHAR(20)),12) AS ST_DATE, RIGHT( CAST(S_DATE AS VARCHAR(2

Try to convert a string to date-time format in vb.net 2005

I can't seem to be able to convert a string that contains date value of "100714 0700" (2010-07-14 7am) to a date format in vb.net 2005 When I attempt to do: Dim provider As Globalization.CultureInfo = Globalization.CultureInfo.InvariantCulture s

How to convert two different strings to date format and find their differences in JSP / JAVA

I have 2 strings Str1: 2016-7-25.15.38. 32. 0 (This is what im getting from DB) String2 : July 25, 2016 3:19 PM (This one I wrote a program to read from the email timestamp) How to convert these 2 strings to date format and find their differnce in ti

Convert long date strings in Excel to a sortable date / time format

I have an Excel spreadsheet full of text dates formatted like this: Thursday, 23 April 2015, 9:19 AM Because they're text, Excel can't sort them chronologically. How do I convert them into a format Excel can work with? Also, for my future reference,

How to convert a date field to date-time format? SQL 2008

The conversion of a date data type to a datetime data type resulted in an out-of-range value. The statement has been terminated. I just need to convert a date field to a date time format.Example of what the code would look like to convert from date t

Convert to date-time format for pandas?

I need help converting into python/pandas date time format. For example, my times are saved like the following line: 2017-01-01 05:30:24.468911+00:00 ..... 2017-05-05 01:51:31.351718+00:00 and I want to know the simplest way to convert this into date

Merge two columns into a single column and format the content to form a specific date-time format in Hive?

these are the 2 columns(month,year). I want to create a single column out of them having an accurate date-time format('YYYY-MM-DD HH:MM:SS') and add as new column in the table. Month year 12/ 3 2013 at 8:40pm 12/ 3 2013 at 8:39pm 12/ 3 2013 at 8:39pm

How to convert nanoseconds of uptime to a readable date time format

I have extracted accerometer data from a android wearable. While looking at the data i realised the timestamp is not unix covertable. After research i saw the timestamp was actually nanoseconds in uptime. My question is the same as Accelerometer Sens

How to update / change the system date time format in the regional and language options of the control panel using the code?

I am looking for code in .NET (C#) to change the system date/time format in Regional Options of the Control Panel for Windows XP.To change date-time format take a look at this http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/263d73b2-86

How can I change the date time formats in Perl?

i want to convert the date time format to that i want. how to convert the date time format from Fri Nov 21 2014 15:04:32 to 2014-11-21 15:04:32 ? thanksTime::Piece has been core Perl for many years. Use strptime (string parse time) to parse your date

If I have a date time format, do I need to display a single time?

I have an application that retrieves a string formatted in date time format from a database, and I want to display only the time in certain instances, how would I accomplish this? This is what I have tried so far but I get an Unparsable error public

Implement LINQ expressions to SQL for a database with a custom date / time format

I'm working with an MS-SQL database with tables that use a customized date/time format stored as an integer. The format maintains time order, but is not one-to-one with ticks. Simple conversions are possible from the custom format to hours / days / m

Change the default date time format on a single database in SQL Server

I need to change the date format from US (mm/dd/YYYY) to UK (dd/mm/YYYY) on a single database on a SQL server machine. How can this be done? I've seen statements that do this for the whole system, and ones that do it for the session, but I can't chan

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK