473,809 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 ('2003100115570 4 ') 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 5132
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 ('2003100115570 4 ') 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_timestam p = strtotime('2003 1001155704');

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 ('2003100115570 4 ') 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_timestam p = strtotime('2003 1001155704');


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_timestam p = strtotime('2003 1001 1557');

--
Tom Thackrey
www.creative-light.com
Jul 17 '05 #3
"Tom Thackrey" <to***@creati ve-light.com> wrote in message news:<bs******* **********@news svr25.news.prod igy.com>...
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('2003100 1155704','%4d%2 d%2d%2d%2d%2d') ;
list($year,$mon th,$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
3002
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 terminated with a newline. This means I can't effectively use split() except on a small scale. For most of the file I can just call one of several functions I wrote that read in just as much data as is required from the input string, and return the...
2
17949
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 appears in double quotes it should not be used for parsing. For example in the simple case we'd have : $a='hello,brave,world';
12
5622
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 window and hit a button to process it. The information thus enters the program as a char array. Prices can be between $1 and $100, including cents. So we can have prices such as 3.01, 1.56, 11.57, etc. The char array is an alphanumeric...
8
2820
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 choice. I'd like to hear from you guys what would be a good implementation in this case. thanks in advance,
9
1479
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 <Delim2> Key <Delim1> Value <Delim3>
16
2045
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 <string.h> int main()
4
1479
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 delimiters back to the struct. For an example: Line in is: Today, Friday 23, is a crazy day. Delimiters is: " ,." /*space, comma and period/* The stuct will get total of 7 words: "Today", "Friday", "23", "is" ..... "day". This is the codes...
3
1268
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 error highlight is highlighting the line below. (arrow) Do MA = Parse(streamLine)
11
3078
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 spaces, but not in the inner string(\"and a inner string\\\"). Will anyone please tell me how to do this?
0
2592
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 split them into tokens. My logic is very simple: construct a regular expression with 'operators and punctuators' which will serve as delimiters and split a string into array of tokens including those delimiters. For example: I have the...
0
9603
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
10640
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
10376
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...
1
10387
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9200
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6881
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
5550
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
5689
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3861
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.