473,788 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

formmating dates?

Im reading a csv file with php and getting a date in the form 30/09/07

Which I am trying to insert into a mysql table which has the field formatted
as yyyy-mm-dd hh:mm:ss
I cant get it to insert the field remains blank
How do I do this?
Nov 11 '07 #1
7 1299
Greetings, mantrid.
In reply to Your message dated Sunday, November 11, 2007, 15:25:41,
Im reading a csv file with php and getting a date in the form 30/09/07
Which I am trying to insert into a mysql table which has the field formatted
as yyyy-mm-dd hh:mm:ss
I cant get it to insert the field remains blank
How do I do this?
strptime may help You.
But be careful about original date format.
--
Sincerely Yours, AnrDaemon <an*******@free mail.ru>

Nov 11 '07 #2

"AnrDaemon" <an*******@free mail.ruwrote in message
news:17******** *************** @freemail.ru...
Greetings, mantrid.
In reply to Your message dated Sunday, November 11, 2007, 15:25:41,
Im reading a csv file with php and getting a date in the form 30/09/07
Which I am trying to insert into a mysql table which has the field
formatted
as yyyy-mm-dd hh:mm:ss
I cant get it to insert the field remains blank
How do I do this?

strptime may help You.
But be careful about original date format.
--
Sincerely Yours, AnrDaemon <an*******@free mail.ru>

Thanks
but not using version 5 so not supported
Ian
Nov 11 '07 #3

"mantrid" <ia********@vir gin.netwrote in message
news:9x******** *********@newsf e2-gui.ntli.net...
Im reading a csv file with php and getting a date in the form 30/09/07

Which I am trying to insert into a mysql table which has the field
formatted
as yyyy-mm-dd hh:mm:ss
I cant get it to insert the field remains blank
How do I do this?

I was able to work around the problem using

$datebits = explode("/", $dateandtime);
$dateandtime = date('Y-m-d
H:i:s',mktime(0 0,00,00,$datebi ts[1],$datebits[0],$datebits[2]));

However, if there is a simple single function I can use, or if anyone knows
a better way please let me know as users may not use the dd/mm/yyy format
but could use something along the lines of dd-mm-yyyy or any other style.
Nov 11 '07 #4
On Nov 11, 10:15 am, "mantrid" <ian.dan...@vir gin.netwrote:
"mantrid" <ian.dan...@vir gin.netwrote in message

news:9x******** *********@newsf e2-gui.ntli.net... Im reading a csv file with php and getting a date in the form 30/09/07
Which I am trying to insert into a mysql table which has the field
formatted
as yyyy-mm-dd hh:mm:ss
I cant get it to insert the field remains blank
How do I do this?

I was able to work around the problem using

$datebits = explode("/", $dateandtime);
$dateandtime = date('Y-m-d
H:i:s',mktime(0 0,00,00,$datebi ts[1],$datebits[0],$datebits[2]));

However, if there is a simple single function I can use, or if anyone knows
a better way please let me know as users may not use the dd/mm/yyy format
but could use something along the lines of dd-mm-yyyy or any other style.
Use strtotime() and date():

date('Y-m-d', strtotime($date andtime));

Nov 11 '07 #5
Greetings, mantrid.
In reply to Your message dated Sunday, November 11, 2007, 16:39:56,
Thanks
but not using version 5 so not supported
Welcome to reality.
http://www.php.net/index.php#2007-07-13-1
--
Sincerely Yours, AnrDaemon <an*******@free mail.ru>

Nov 11 '07 #6
Thanks will give it a go
Ian
"ZeldorBlat " <ze********@gma il.comwrote in message
news:11******** *************@d 55g2000hsg.goog legroups.com...
On Nov 11, 10:15 am, "mantrid" <ian.dan...@vir gin.netwrote:
"mantrid" <ian.dan...@vir gin.netwrote in message

news:9x******** *********@newsf e2-gui.ntli.net... Im reading a csv file
with php and getting a date in the form 30/09/07
Which I am trying to insert into a mysql table which has the field
formatted
as yyyy-mm-dd hh:mm:ss
I cant get it to insert the field remains blank
How do I do this?
I was able to work around the problem using

$datebits = explode("/", $dateandtime);
$dateandtime = date('Y-m-d
H:i:s',mktime(0 0,00,00,$datebi ts[1],$datebits[0],$datebits[2]));

However, if there is a simple single function I can use, or if anyone
knows
a better way please let me know as users may not use the dd/mm/yyy
format
but could use something along the lines of dd-mm-yyyy or any other
style.
>
Use strtotime() and date():

date('Y-m-d', strtotime($date andtime));

Nov 12 '07 #7
ZeldorBlat wrote:
Use strtotime() and date():
date('Y-m-d', strtotime($date andtime));
If you know that DMY dates are more likely than MDY dates, strtotime() can
be problematic. In the case of an ambiguous date (e.g. 01/02/08) it will
always assume MDY, which will be wrong in the majority of cases (less than
10% of the world uses MDY dates).

I recommend taking a look at my strtotime_i18n( ) function which takes two
parameters: the date string, plus a hint of the form 'dmy', 'mdy' or
'ymd':

http://demiblog.svn.sourceforge.net/...hp?view=markup

Something like '01/28/2008' will always be parsed as 28 Jan 2008 as there
is no 28th month, but in ambiguous cases, it should help you out. If you
want to use it, you may want to rewrite the small part at the top of the
function which checks if $assumption==NU LL. It relies on some other
functions and objects in my project, which you're less likely to want to
use.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 7 days, 26 min.]

TrivialEncoder/0.2
http://tobyinkster.co.uk/blog/2007/0...ivial-encoder/
Nov 13 '07 #8

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

Similar topics

8
5332
by: Riley | last post by:
The date fields being saved by a VB program were being saved as #2003-11-22#. For reasons unknown to me these dates began to be saved as "11/22/2003" All of these dates were made dates with the "DateValue" instruction and when used as input to Excel both formats sort as dates but not intermingled. All "11/22/2003" formated dates sort in date order but before the #2003/11/22#. What would cause the format of these dates to change and what...
5
2144
by: PW | last post by:
<rant> Sorry guys, but I just have to whinge. Dates in ASP are a total pain in the butt! I seem to get caught out so many times. I realise its my own fault, but going from the posts in this newsgroup and others, I'm not the only one. Its just a poorly addressed issue within ASP. So for all your poor buggers out there that are having problems, particularly with european date formats, here is my solution. I have the user enter their...
10
3296
by: Colin Steadman | last post by:
I'm a stupid ASP programmer and I dont do Javascript (except for very simple tasks anyway), and I'm in a bit of a predicament. I've used a javascript table sorting script from here: http://www.ipwebdesign.net/kaelisSpace/useful_tableSort.html This works great except it doesn't sort my UK formatted dates properly, and I end up with something like this: Birth Date (dd/mm/yyyy)
1
2130
by: Don Sealer | last post by:
I have a report that includes 5 different subreports. I'd like to be able to open this report using a date function (Start Date and End Date). I'd like all five subreports to show the data from those dates. I have learned how to use this start/end function but I can't figure out how to use it with these subreports. Right now the report opens but asks for start/end dates for each of the five reports. Is there a way I can input one set of...
2
3330
by: Rachel Suddeth | last post by:
Is there a way to have the non-selectable dates (those before MinDate and after MaxDate) draw differently so my users can see right away what dates aren't allowed? I'm not seeing it... Otherwise, anyone know of a cheap 3rd party calendar control I could use that would provide that ability? Thanks, Rachel
12
2443
by: Dixie | last post by:
I am trying to calculate the number of workdays between two dates with regards to holidays as well. I have used Arvin Meyer's code on the Access Web, but as I am in Australia and my date format is dd/mm/yyyy, I have found that the dates I put in my holidays table are reversed into American dates. So, the wrong holiday dates are subtracted from the total workdays between the start and end dates. Is there an easy fix for this? ******Code...
1
15785
by: pitfour.ferguson | last post by:
My dbase has the start date and end date of each visit. How can I ask Access to list the day of the week of the start (easy), end (easy) and, more importantly, the dates of the visit itself - ie list the dates between the start and end date. Basically I am doing a day of the week analysis and need to know which day of the week is busiest.
7
2419
by: evilcowstare via AccessMonster.com | last post by:
Hi, I have searched the forum for answers on this and to be honest as a novice I find it a bit confusing so apologies if it is simple. There are some searches that I want to apply to my database. 1. To search for all records between 2 dates and display them in a report 2. To be able to show all records which have a selection against them made from a combo box 3. To be able to combine the two, selecting the option from a combo and then...
2
2197
by: Jim Carlock | last post by:
(1) Does PHP provide any way to handle dates prior to 1980? I know there's problems with Microsoft Windows NT and all Windows NT operating systems will allow a date prior to 1980 to be placed upon a file, but it ends up not being able to display the date (probably an Windows Explorer specific issue). (2) I'm looking for for ways to store dates and process dates (dates only). This probably ends up as a database specific issue, so I'm...
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
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
10177
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
9969
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
7519
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
6750
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
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.