473,396 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Parsing a PHP String without Delimiters

I'm not sure if my last post went through (so my apologies if this is a repeat).

I need to figure out how to separate a string that contains no delimters.
In this case, a MySQL timestamp ('20031001155704 ') into date and time units.

Is there a date function for this?
If not, I would be just as happy with a string function.

Thanks,
Chris
Jul 17 '05 #1
3 5098
cm******@yahoo.com (AttilaTheChris) wrote in message > I need to figure out how to separate a string that contains no delimters.
In this case, a MySQL timestamp ('20031001155704 ') into date and time units.

Is there a date function for this? A question that can be answered easily on your own..
http://www.php.net/
why wait hours when you can have immediate answers.

http://us3.php.net/manual/en/function.strtotime.php
and look at all those other handy date functions on the left.

$epoch_timestamp = strtotime('20031001155704');

or perhaps you should be using a mysql date function (see http://www.mysql.com)?
If not, I would be just as happy with a string function.

Jul 17 '05 #2

On 1-Oct-2003, Br******@swbell.net (BKDotCom) wrote:
cm******@yahoo.com (AttilaTheChris) wrote in message > I need to figure
out how to separate a string that contains no delimters.
In this case, a MySQL timestamp ('20031001155704 ') into date and time
units.

Is there a date function for this?

A question that can be answered easily on your own..
http://www.php.net/
why wait hours when you can have immediate answers.

http://us3.php.net/manual/en/function.strtotime.php
and look at all those other handy date functions on the left.

$epoch_timestamp = strtotime('20031001155704');


Before you cast the RTFM stone you might want to RTFM yourself.

strtotime does not parse '20031001155704' you have to remove the seconds and
add a space between the date and time to make it work i.e.
$epoch_timestamp = strtotime('20031001 1557');

--
Tom Thackrey
www.creative-light.com
Jul 17 '05 #3
"Tom Thackrey" <to***@creative-light.com> wrote in message news:<bs*****************@newssvr25.news.prodigy.c om>...
Before you cast the RTFM stone you might want to RTFM yourself.


I guess bum-info is one of the hazzards of usenet?

How about this?
$array = sscanf('20031001155704','%4d%2d%2d%2d%2d%2d');
list($year,$month,$day,$hour,$min,$sec) = $array;
Jul 17 '05 #4

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

Similar topics

7
by: Kylotan | last post by:
I have a text file where the fields are delimited in various different ways. For example, strings are terminated with a tilde, numbers are terminated with whitespace, and some identifiers are...
2
by: GIMME | last post by:
I can't figure an expression needed to parse a string. This problem arrises from parsing Excel csv files ... The expression must parse a string based upon comma delimiters, but if a comma...
12
by: BGP | last post by:
I am working on a WIN32 API app using devc++4992 that will accept Dow Jones/NASDAQ/etc. stock prices as input, parse them, and do things with it. The user can just cut and paste back prices into a...
8
by: netbogus | last post by:
hi, I have a file stored in memory using mmap() and I'd like to parse to read line by line. Also, there are several threads that read this buffer so I think strtok(p, "\n") wouldnt be a good...
9
by: Ravi Singh (UCSD) | last post by:
Hello all I have a huge string that I need to parse Key <Delim1> Value <Delim2> Key <Delim1> Value <Delim2> Key <Delim1> Value <Delim3> Key <Delim1> Value <Delim2> Key <Delim1> Value...
16
by: Amit Gupta | last post by:
Hi - I get a seg-fault when I compile and run this simple program. (seg-fault in first call to strtok). Any clues? My gcc is "gcc version 4.1.1 20070105 (Red Hat 4.1.1-51)" #include...
4
by: nnguyec | last post by:
Hi, I'm trying to write a small code for an assignment which the void String Tokenizer will get a line input, and take out those delimiters from the original string. Then pass each string without the...
3
by: Necromis | last post by:
The below code is giving me an error of..... "System.NullReferenceException was unhandled Message="Object reference not set to an instance of an object." ......in this line........ the yellow...
11
by: ramu | last post by:
Hi, Suppose I have a string like this: "I have a string \"and a inner string\\\" I want to remove space in this string but not in the inner string" In the above string I have to remove...
0
by: ahropak | last post by:
Hi, I have a question regarding a regular expression within Regex.Split() method which will help me to break each line of code into tokens. I'm trying to parse some lines of C# source code and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.