473,659 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert 20080928014155 to date time in perl?

2 New Member
I have 2 questions:
1.When I read the number using (\S+) its getting stored as 2.08E13.
Code I used:
Expand|Select|Wrap|Line Numbers
  1. if ($line=~/4_begindt_(\S+)/) {
  2. print "$1\n"    }
  3. # $1=2.08E13; instead $1 should contain 20080928014155
  4.  
How to read and store a 15digit number in perl?

2.Once I store the number how do I convert to date and time?
like 09/28/2008 01:41:55

Please let me know
Oct 1 '08 #1
7 1849
Icecrack
174 Recognized Expert New Member
First off Use Code Tags,

Second don't store var's as $0 - $9 this is perl Special Var's

3rd, Try:

Expand|Select|Wrap|Line Numbers
  1. $a=20080928014155;
now try this your self we are not a scripting/programing service when you do, paste code with errors or problems.
Oct 1 '08 #2
KevinADC
4,059 Recognized Expert Specialist
When I do this:

Expand|Select|Wrap|Line Numbers
  1. $line = '4_begindt_20080928014155';
  2. if ($line=~/4_begindt_(\S+)/) {
  3.    print "$1\n";
  4. }
the output is: 20080928014155
Oct 1 '08 #3
KevinADC
4,059 Recognized Expert Specialist
First off Use Code Tags,

Second don't store var's as $0 - $9 this is perl Special Var's

3rd, Try:

Expand|Select|Wrap|Line Numbers
  1. $a=20080928014155;
now try this your self we are not a scripting/programing service when you do, paste code with errors or problems.
I think you misunderstood. He is not using $1 as a private variable but as the capturing group from the regexp, he just added the "=" symbol to show what its value is and what he wants it to be.
Oct 1 '08 #4
Icecrack
174 Recognized Expert New Member
When I do this:

Expand|Select|Wrap|Line Numbers
  1. $line = '4_begindt_20080928014155';
  2. if ($line=~/4_begindt_(\S+)/) {
  3.    print "$1\n";
  4. }
the output is: 20080928014155

that would be correct because of the reg exp the $1 prints first of the last reg exp matched.

what OS are you using as well?


Note: yeah just seen that. because of the non code tags i missed the #
Oct 1 '08 #5
brainbox
2 New Member
I am using Windows.
Thats true I am capturing the whole number into $1 using regex.
Should code tags be used for capturing large numbers using regex, ?
Oct 1 '08 #6
numberwhun
3,509 Recognized Expert Moderator Specialist
To convert the string of numbers into the format you want, you will probably have to look at one of the data modules on CPAN, such as this one. But there are a bunch of others depending on what you want to do.

Regards,

Jeff
Oct 1 '08 #7
KevinADC
4,059 Recognized Expert Specialist
I am using Windows.
Thats true I am capturing the whole number into $1 using regex.
Should code tags be used for capturing large numbers using regex, ?
The "code" tags is for posting code on this forum, nothing to do with perl. I am also using my old W98 server with activeperl 5.8.8 installed and I do not get the output you are getting. Is there more to your code?
Oct 1 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
8671
by: Manzoorul Hassan | last post by:
I need to convert a date / time to NTP Timestamp, in HEX no less, and was wondering if there might be a module for it. Any ideas? I have been searching for NTP Timestamp under Perl but have not found much - yet. - manzoor
10
2360
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,
2
4948
by: yxq | last post by:
Hello, I found there are some date formats in the email header, for example: Fri, 23 Sep 2005 08:51:56 +0800 Sat, 17 Sep 2005 09:08:07 Wed Oct 19 13:40:23 2005 19 Oct 2005 13:40:23 +0000 19 Oct 2005 13:40:23 -0400
5
43848
by: Ray | last post by:
I have a table with some audit date and time columns. Problem is the developer who stored the data left them as DECIMAL type instead of DATE and TIME. Is there a way I can convert the DECIMAL type to DATE or TIME? The column data is in the date form YYYYMMDD (i.e. 20060308 = March 8 2006). I want to get the data into a DATE type. I tried TO_DATE('20060308','YYYYMMDD') but I cannot get it to work. What else can I do to conver the data...
5
5707
by: Extremest | last post by:
I have a bunch of dates in a couple different formats. I would like to convert them to epoch. The dates are like this Mon, 12 Jun 2006 09:18:22 GMT 12 Jun 2006 10:37:28 GMT I can do this in perl easily with the Date::Manip module but don't know how to do it in c#. Is there a way to do this or do I need to right something to parse each date?
8
6046
by: deepak_kamath_n | last post by:
Hello, I have the following scenario: 1. My application receives the date from another application as a string 2. The other application is running in a different time zone as compared to my app. 3. I need to convert the received date string in to a date w.r.t my local time zone.
12
3162
by: jonathan184 | last post by:
Hi the purpose of the script I am trying to do is to access a dir and run the ls -l command which will show the files and the modified date, no w the script is to check two files in that dir , if the file has the modified month and day matching today print message log is fine else the log is not updated and thats it. Now the script below I managed to parse to get both month and day for the files and the perl day and month now the script...
3
8289
by: Rocko | last post by:
Hi, Wishing you a very Happy New Year!! I am new to perl and I need to know that how to get the current date & time in my perl script. I am working on Windows XP. my code snippet is like this: #! usr/bin/perl -w $logfilename = "logfileLOV"; $dateAndtime = `date`; $dateAndtime =~ tr// /;
1
47445
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
0
8427
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
8332
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
8746
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
8627
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...
0
7356
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...
1
6179
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
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
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.