Jump to content

Time conversion...


CSmith1128

Recommended Posts

Hello.. I have a pretty simple question probably.. but for some reason I cannot think right now and cannot figure it out...

 

I need to convert this: 1:11 PM to the mysql date format.

 

So the format that CURDATE() is in i need it converted to.

 

First, what format is CURDATE() in?  Just for reference.

 

And second, how would I convert it? I am given the hour from 1 to 12, minutes, and AM or PM.

 

 

Thanks!

 

-Chris

Link to comment
Share on other sites

And I dont have to worry about converting it?

 

I have a form where a visitor can enter a time.

 

There's an hour, minute, and am/pm drop down selector so they can choose the time.

 

So I get the hour, minute, and am/pm separately.

 

The format I get it in isn't in the timestamp format.

 

The mysql field is in the TIME format.

 

So I have to convert the hour, minute, and am/pm to whatever format CURTIME() is in. (sorry, I said CURDATE in my first post)

 

Is there a function to do that?

Link to comment
Share on other sites

Why don't you just google your answers? I found all your answers just by google'ing. If you need a SCRIPT that you have written help with, then you come to this section. Search before you ask most of them, because there is a large chapter in php and mysql regarding TIMESTAMPS and DATES,.

Link to comment
Share on other sites

Then we can can shut down this site since most problems people have have probably been encountered before anyway by someone else. It's all in Google - you don't need us. Just find that large chapter in php and mysql.

 

@phpSensei, can I quote you next time you post a question?

 

???

 

What I ment

 

If you need a SCRIPT that you have written help with, then you come to this section.

 

This is a common DATE question which has been answered many times before. You can refer to this site's search tool to answer your question or google it. By "Large" chapter I ment was a whole lot of info you can just fly by in the manual and find the answer. Also, PHPfreaks, dispite the name, isn't just about PHP questions, or googl'ing all of them. People mostly want to create custom scripts and so we help them. But this is a function or one category question, so its best off google'd.

 

 

Link to comment
Share on other sites

phpSensei,

 

You might want to read this ropic

 

http://www.phpfreaks.com/forums/index.php/topic,166260.0.html

 

Back in my Noob Days thankyou for that topic, but thats just my point. I actually didnt know how to ALTER a Mysql Table either...

 

You told me to look at the manual dude, but it was a very short search I did, and found the answer in no time. Just like this case...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.