Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Date and time

Posted on 2014-04-03
3
Medium Priority
?
345 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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

609 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