[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Date and time

Posted on 2014-04-03
3
Medium Priority
?
346 Views
Last Modified: 2014-04-04
Hi,

I have jquery date and time picker that I want to insert into my database.

My database data type field is datetime. the value for the text field is "04/03/2014 12:51 pm"

how can I convert from this:

 "04/03/2014 1:51 pm"

to  military

 "04/03/2014 13:51"


$('#TimeResolvedTxt').timepicker({
	hourGrid: 4,
	minuteGrid: 10,
	timeFormat: 'hh:mm tt'
});


$('#DateResolvedtxt').datetimepicker({
	timeFormat: "hh:mm tt"
});

Open in new window



 <input id="DateResolvedtxt" name="DateResolvedtxt" data-format="MM/dd/yyyy" type="text" style="height:23px;width:205px;text-align:center;"/>

<input id="TimeResolvedTxt" name="TimeResolvedTxt" data-format="hh:mm:ss" type="text"
     					style="height:23px;width:195px;text-align:center;"/>

Open in new window



 <cfif IsDefined('FORM.DateResolvedtxt') and isDate(form.DateResolvedtxt)>
      <cfqueryparam value="#form.DateResolvedtxt#" cfsqltype="cf_sql_timestamp"> ,
<cfelse>
      NULL ,
</cfif> 

Open in new window

0
Comment
Question by:lulu50
3 Comments
 
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 39975933
Are you trying to put the date and time to an input field from your database?  Wouldn't be easier to use you server side code to parse this out?

I have used keith wood's site for this (and a few other things) http://keith-wood.name/timeEntry.html  The jquery plug in is ready to go.  
('#show24').timeEntry({show24Hours: true});

Open in new window

0
 
LVL 16

Accepted Solution

by:
Gurpreet Singh Randhawa earned 2000 total points
ID: 39977372
Use your server side to do what you are trying to here

if you are using coldfusion 10:

<cfif IsDefined('FORM.DateResolvedtxt') and isDate(form.DateResolvedtxt)>
      <cfqueryparam value="#DateTimeFormat(form.DateResolvedtxt,'mm/dd/yyyy HH:nn')#" cfsqltype="cf_sql_timestamp"> ,
<cfelse>
      NULL ,
</cfif>

Open in new window


If you are on Coldfusion 9 or below do like this:

<cfif IsDefined('FORM.DateResolvedtxt') and isDate(form.DateResolvedtxt)>
<cfset dt = DateFormat(form.DateResolvedtxt,'mm/dd/yyyy') & TimeFormat(form.DateResolvedtxt,'HH:mm')>
      <cfqueryparam value="#dt#" cfsqltype="cf_sql_timestamp"> ,
<cfelse>
      NULL ,
</cfif> 

Open in new window

0
 

Author Closing Comment

by:lulu50
ID: 39978091
Thank you
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses
Course of the Month18 days, 14 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question