Re: Date subroutine by jettero (Monsignor) on May 16, 2007 at 10:45 UTC |
use strict;
use warnings;
open my $otherfile, ">", "otherfile.txt" or die $!;
print $otherfile scalar localtime, "\n";
| [reply] [d/l] |
Re: Date subroutine by naikonta (Curate) on May 16, 2007 at 10:56 UTC |
rashmi_k28, what date subroutine are you talking about? Does it come from CPAN module or your module? Are you talking about the date Linux command line?
my $date = qx/date/;
Are you looking for the equal of PHP date() function in Perl? There's no such built-in function in Perl, but jettero has shown an example as well. Or, there are various CPAN modules available to work with various aspects of date. You can also use the strftime() function in POSIX.
use POSIX 'strftime';
my $today = strftime '%d-%m-%Y', localtime;
Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!
| [reply] [d/l] [select] |
|
$tt1=date(114454234);
I am not able to convert from_unixtime value to date format.
In database I am using timestamp value. If i insert from_unixtime value i get "0000"
Using date(114454234) I am getting undefined subroutine.
How should i call the date subrountine where it should be declared
| [reply] |
|
Where is the date subroutine? It's not in Perl or its base modules. There is, however, a localtime function that may do what you need.
It also looks like you've asked a remarkably similar (and equally ungrammatical) question here.
emc
Insisting on perfect safety is for people who don't have the balls to live in the real world.
—Mary Shafer, NASA Dryden Flight Research Center
| [reply] |
Re: Date subroutine by shmem (Canon) on May 16, 2007 at 11:27 UTC |
Please use the Chatterbox for such trivial one-shot questions. No need to start a thread.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
| [reply] |
Re: Date subroutine by Tomte (Priest) on May 16, 2007 at 11:29 UTC |
What did you try? Why don't you read the documentation? Do you think your computer or we here should be able to read your mind?
here is my testrun, everything works as it should - don't just make something up in your head and falter surrender if that failes, read the documentation carefully, experiment with the stuff you read and think:
mysql> create table tstest( ts timestamp not null default now());
Query OK, 0 rows affected (0.03 sec)
mysql> insert into tstest values(from_unixtime(114454234));
Query OK, 1 row affected (0.00 sec)
mysql> select * from tstest;
+---------------------+
| ts |
+---------------------+
| 1973-08-17 17:50:34 |
+---------------------+
1 row in set (0.00 sec)
Edit: altered a word to get nearer to the intended meaning...(marked via strike out)
regards,
tomte
An intellectual is someone whose mind watches itself. -- Albert Camus
| [reply] [d/l] |
|
Timestamp from 1973???? only hour format how can it be inserted
| [reply] |
|
The value you get by taking the difference of two timestamps is not a timestamp, but an intervall - and that intervall cannot be inserted as just hours - a timestamp is a defined moment in time, not an intervall - as I mentioned here you are simply using the wrong type for that column.
Please stop spamming the monastery with your rubbish postings - read
and please above all, read the documentation for the tools you use, namely MySQL in this case, and try to understand the problem you are about to solve before you come up with solutions that aren't likely to work because you don't understand the problem at hand - that seems to be the case here.
I'm a bit fed up with your behaviour here - posting, multiple times, without content, in the wrong sections, creating new accounts to make the same mistakes again - you are misusing a wonderful place, and with that you are taking away from yourself the opportunity to learn something from all the wonderful, helpful poeple here - kind of sad...
regards,
tomte
An intellectual is someone whose mind watches itself. -- Albert Camus
| [reply] |
Re: Date subroutine by blazar (Canon) on May 16, 2007 at 12:09 UTC |
How to use the date subroutine.
Is that a question? If so, then it's missing a question mark. However the answer is "just like thus:"
my @output=date(@args);
What should be in @args and what should end up in @output depends on the actual date sub.
How to use the date subroutine and pass the value in other file
Another question? Still missing a question mark. However the answer is "just like thus:"
print $otherfile date(@args);
| [reply] [d/l] [select] |
Re: Date subroutine by swampyankee (Parson) on May 16, 2007 at 15:29 UTC |
"How to use the date subroutine."
Leaving out snarky comments about its object oriented interface, partner -> find_member_of_appropriate_sex
and complaints about your punctuation, look to convert seconds since the epoch to a list containing the time and date, and the various time-related functions in the Posix module, where you could take a look at strftime and asctime.
emc
Insisting on perfect safety is for people who don't have the balls to live in the real world.
—Mary Shafer, NASA Dryden Flight Research Center
| [reply] |