for converting mm/dd/yy to yyyy-mm-dd, I used this code
list($d, $m, $y) = preg_split('/\//', $normal_date);
$mydate = sprintf('%4d%02d%02d', $y, $m, $d);
print $mydate;
following date is not converted
10/20/2011 ( that is to say, if both month and date are 2 digts)
whereas rest of the excel dates are being converted
2/12/2011
6/10/2011
pl help
3 2634
use mktime function to convert to time. Then give that to the date function choosing the format that you want. -
$mydate = date('Y-m-D',mktime(0,0,0,$d,$m,$y));
-
For me it's working fine.
Also, I agree with "dlite22", you should use PHP provided functions extensively to avoid any bugs and all.
You can also thik of getting rid of regex preg_split() it slows down the execution. Use some string based functions to split it up
@dlite22,
I think it should be small d in place of capital D in date() - $mydate = date('Y-m-d',mktime(0,0,0,$d,$m,$y));
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Monica Roman |
last post by:
Hello, help please.
I have a little macro that copies the date from a date/time field to a
memo field, BUT instead of going to the memo field it finds the first
date/time field and tries to copy...
|
by: MLH |
last post by:
Does
Date = Date + 1
mean
Date Statement equals Date Function plus 1?
And if the answer is Yes, how much actual time
is being added to the date function in this assignment?
|
by: Narshe |
last post by:
I'm using the excel object from office web components in an asp.net
webpage. I have 2 major issues.
When a user hits enter on a cell, it moves cells. That's fine, 'cause
that's how excel...
|
by: Me |
last post by:
I need to get the past 5(x) months for certaing calculations. What I
have is listed below:
########################################
my $year, $month_str, $month_int;
foreach my $count...
|
by: ScardyBob |
last post by:
Hello,
I am having trouble importing data from an Excel Worksheet. When I try
to import the data, everything works except certain columns that
contain dates, where it replaces the date with a...
|
by: lyndac |
last post by:
Hello!
Last night a job to create a view using DATE(CURRENT DATE - 1 DAY) received the current days date instead the previous days date.
Any one know why/how this can happen?
The...
|
by: grego9 |
last post by:
I have a problem in Excel 2000. I have written some VBA code that transfers data from the current excel workbook to a file called "Deal Input2.xls". Everything transfers ok apart from the date in...
|
by: dkyadav80 |
last post by:
hi sir,
I have following problem:
code goes here:
{code]
1.
<html>
2.
<body>
|
by: viditsinghal |
last post by:
I need to write a C++ function that takes date as input and return day of the week as output.
Can i get it somewhere where all the possiblibilies are covered.
-Regards
VS
|
by: code green |
last post by:
Within a stored procedure I am creating a table from an Excel spreadsheet /*Create tmp table from XLS*/
SELECT * INTO tmp_cons FROM
OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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,...
|
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...
|
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...
| |