473,778 Members | 1,910 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP Equivalent of MySQL STR_TO_DATE()?


I have an application where I would like to be able to allow the user
to specify the date format used throughout the program (for
internationaliz ation).

Then, on a date entry field, I can specify the date format on a MySQL
SELECT to get the date in the proper format.

The Javascript date selector I am using allows me to specify the
format for selecting the date.

Where I am having problems is posting the date back to MySQL. If I was
using v4 of MySQL, I could use STR_TO_DATE(). However, I need to be
able to support version 3 of MySQL, so I need a PHP equivalent to
convert the date in the user-defined format to the MySQL date format.

I can use date() to get a timestamp into the proper format, but how do
I get the user-defined format into a timestamp? strtotime() was the
closest I could find, but that doesn't look like it is going to work
for any format.

Has anyone else run into this? Is there a solution?

--Bruce

Jul 17 '05 #1
1 9471
Bruce <bv************ ***@mailblocks. com> wrote in message news:<on******* *************** **********@4ax. com>...
<snip>
I can use date() to get a timestamp into the proper format, but how do
I get the user-defined format into a timestamp? strtotime() was the
closest I could find, but that doesn't look like it is going to work
for any format.


May try <http://www.phpinsider. com/php/code/Date_Calc/>

--
http://www.sendmetoindia.com - Send Me to India!
Email: rrjanbiah-at-Y!com
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5656
by: JBBHF | last post by:
Hi i'm working on a web project, and i would like to make my oracle query work in mysql. select match.numero "nummatch", to_char(match.datematch, 'yyyy-MM-dd') "datematch", p1.numjoueur "j1", p2.numjoueur "j2", po1.p1 "m1p1", po1.p2 "m1p2", po2.p1 "m2p1",
2
2241
by: Gnurp Gnarp | last post by:
How do I prevent the MySQL client to scroll pages when the results of a query exceeds the number of lines in the terminal window? Like a MySQL equivalent to *nix 'more'. mysql> select foo from bar; 2500 rows in set (0.00 sec)
2
1536
by: Phil Nospam | last post by:
Hello all, I was browsing through the reference manual on the mysql.com web site and found the following code examples for some date/time functions: mysql> SELECT STR_TO_DATE('00/00/0000', '%m/%d/%Y'); -> '0000-00-00' mysql> SELECT STR_TO_DATE('04/31/2004', '%m/%d/%Y'); -> '2004-04-31'
10
2374
by: Newsscanner | last post by:
Hello, In my MySQL database, one of the fields eople have to fill in is "DOB" (Date of Birth). I have now managed to begin inserting data into my DB via a form, the data type for the DOB field is "DATE", but every time I add data and then check my db, I see the DOB displayed as "0000-00-00". Has anyone got any idea how I could put this right? TIA,
4
3334
by: Dan Lewis | last post by:
I've imported a ms access database into a table in a mysql database. The access database contains a field that holds date/time values in 'general date' format. These all show up at 01/01/1970 in the mysql database. I believe the field in mysql is wanting UTC and shows numbers when looked at from the sql command line (i.e. March 13, 2006, 5:31 pm is shown as 1142289086). How do I get the access data into that format so it will import...
1
2171
by: sang | last post by:
Sir My table name ss with the field cur_date data type varchar() show create table ss; +-------+----------------------------------------------------------------------- ---------------------------+ | Table | Create Table | +-------+-----------------------------------------------------------------------
4
3053
by: Chris Tate-Davies | last post by:
Hello. I have a generic table used for many different generic functions. the fields are mainly varchar's but one of these varchars contains dates (in the format dd/mm/yyyy) for one reason or another. My question is, can I perform a query on this table, using date functions on this varchar field? I.e. search for the latest date? Thanks, Chris
8
3057
by: Tony B | last post by:
I have a string in a existing php script which is in the form "dd/mm/yyyy" and I need to convert it into a suitable format for mysql which is "yyyy-mm-dd" Is there a neat way of doing this in php ?
2
2972
by: electronik | last post by:
I dont really have a problem, but I want to make my code faster and prettier. I have some tables with DATETIME in it. They have the std format %Y-%m-%d %H:%i:%s I need them to be in %d.%m.%Y %H:%i format. I tried to fix it with the server variable "datetime_format". After reading a lot in mysql doc I found out that: http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html
0
9470
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10127
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9923
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7475
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6723
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5500
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2865
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.