How to get Date and Time value in a variable

Content-type: text/plain; charset=iso-8859-1
Content-transfer-encoding: 7BIT

Hi all,

I thought getting the date would be like how it's in a shell script `date` but it does not seem to be working.  Could someone please advise me on this I tried searching archives on "date" but didn't get anything useful.  It's possible I'm looking in the wrong place.

Thanks in advance

6/12/2002 5:46:32 PM
perl.beginners 29148 articles. 1 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 6

On Jun 12, Leila Lappin said:

>I thought getting the date would be like how it's in a shell script
>`date` but it does not seem to be working.  Could someone please advise
>me on this I tried searching archives on "date" but didn't get anything
>useful.  It's possible I'm looking in the wrong place.

Don't use the shell.  Perl provides you with the localtime() and
time() functions.

  perldoc -f localtime
  perldoc -f time

Perhaps if you tell us what format you want the date and time in, we could
be of more service.  But even before you ask us that, I direct your
attention to the POSIX::strftime() function, which takes a format string
similar to the /usr/bin/date program.

  perldoc POSIX
  man strftime

Jeff "japhy" Pinyan
RPI Acacia brother #734
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]

6/12/2002 2:45:58 PM
on Wed, 12 Jun 2002 17:46:32 GMT, (Leila
Lappin) wrote: 

> please advise me on this I tried searching archives on "date" but
> didn't get anything useful.  It's possible I'm looking in the
> wrong place. 


    	perldoc -f localtime

6/12/2002 2:48:02 PM
On Wednesday, June 12, 2002, at 10:46 , Leila Lappin wrote:
> I thought getting the date would be like how it's in a shell script `date`
>  but it does not seem to be working.  Could someone please advise me on 
> this I tried searching archives on "date" but didn't get anything useful.
>   It's possible I'm looking in the wrong place.

there are possibly two issues here - the first suite I
believe have already been answered with the standards,
although I must add

	perldoc Time::localtime

if you are more 'oo' in your approach.

The second problem is whether or not you were doing one of the
classic 'cut over to perl' issues of how do I invoke an external
shell command a la

	vladimir: 61:] sh
	$ DTG=`date`
	$ echo $DTG
	Wed Jun 12 08:53:16 PDT 2002
	$ perl -e 'my $DTG =`date` ; print $DTG'
	Wed Jun 12 08:54:23 PDT 2002

you will note that in the 'command line' version of 'perl -e'
I have done what many would consider 'overkill' since I have

	my $DTG = `date`;

since of course as you grow more accustom to doing things in
perl you will of course want to use strict and the '-w' flag.

but what you mostly want is really

	$ perl -e 'my $DTG=localtime() ; print "$DTG\n";'
	Wed Jun 12 09:00:01 2002
	$ perl -MTime::localtime -e 'my $now = ctime(); print "$now\n";'
	Wed Jun 12 09:04:34 2002




6/12/2002 4:05:29 PM

Similar Artilces:

Date entered...add time value to make date/time field
Windows XP Professional InfoMaker v 9.0.2 Build 7509 Our database contains a date/time stamp for when a specific activity happens to each shipment. I would like the users to be able to simply enter a date for a specific work day. I need to get a list of shipments where the time of one activity occurred on the entered date prior to 9:20. How can I create a computed field that will basically concatenate/amend the entered date with 9:20 that will later be used for criteria in returning rows? Thanks in advance for any help you can provide! Rita Palazzi Senior Engineer /...

date/time or date and time
I am setting up an SQL database and I will need to get differences in dates. For example I have a start date, start time, completion date and completion time and I want to get the difference between the start and completion. Would it be better to have one field with both date and time in it, or better to have a date field and a time field? Even though I have already started setting up the tables with seperate fields for date and time I am now leaning toward one field with date/time in it. (Only because that is the way I had to do it when setting up an Excel spreadsheet for a similar ta...

Does Date variables still keep time info of DateTime values ?
I have the following question that was created by a small mistake I did. I have a dw that refers to a date column in Oracle. By mistake I declared this column as Date (myDate) instead of DateTime. When I tried to place the value of this column to another dw using the explicit datatype conversion DateTime(myDate), I noticed that there was also the correct time present ........!!!!! Does PB keep time info on Date variables ? (I though that during the time of assignment operator '=' there should be something like SQL-truncate function performed. Any advice would be hel...

How to get session variable value into a static variable
Hi, On page preinit i am adding few session variables. Now i want to retrive these session variable values into my static variables. protected void Page_PreInit(object sender, EventArgs e) {Session.Add("T", "Default"); Session.Add("T1", "Red"); Session.Add("T2", "Blue");   }   i have few static variables which shud contain these vaules.  public string TT; public string TT1; public string TextForeColor =sess = "#FFFFFF";   i want to get T value into TT ... T1 into TT1..and so on &n...

how to get variable value by using variable name as parameter???
I have a problem as following; I want to give my variable name as parameter to a function, then get value of that variable. Like this; dim myValue, myVariable, result  as stringmyValue = "demo"myVariable = "myValue"result = SomeMagicFunction(myVariable)then value of result sould be demoI know that is an interesting case. But i need this. :( Please help me !!... If you explain the situation where it is going to be used, there may be some other alternative solution to it. One solution is to store value in a property of a class or structure and then later on use reflection to retrie...

remove time part from a date/time field value
How does one remove or avoid the time part from a date/time field value. For example store 12/12/2006 instead of 12/12/2006 12:00:00 Am --------------------------------------------------No Project Too Eazy.-------------------------------------------------- You can use one of the appropriate Standard DateTime Format Strings such as d or D.Darrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you! You should be able to use DateTime dt = DateTime.Now dt.ToString("d")  //this will format as short date time FYI: If you want to do it at the query ...

How to combine a date and time value to create a DateTime value to the data
I'm using Delphi 7 and MS SQL Server. In my parameterized SQL statement, I have a parameter named "CycleAutoActTime" which is a DateTime column in the DB. "sHoldCreateDate" is a string value such as "1/3/2011" and "rzmefCreateTimeValue.Text" is a value such as "10:30". Which of the following possibilities is the best way to assign the parameter: 1) {code} qryConfigPeriodCycle.Parameters.ParamByName( 'CycleAutoActTime').Value := sHoldCreateDate + rzmefCreateTimeValue.Text; {code} 2) {code} qryConfigP...

How to remove the date part of a Date/Time value in MS Access
I am inserting a time value into a MS Access Date/Time field and notice that MS Access does not display the date portion of the value but when I look at the same data in my programming using a TADOTable component I am seeing the date of 12/30/1899 in conjunction with my time value. I read that Access is handling this within MS Access so that when a 0.sometime value is inserted it does not display the date. How do I handle this within my Delphi program so that I can display the time only in a Date/Time type field? Jeff Howard wrote: > I am inserting a time value into a MS Access Date/T...

How to get powerbuilder library version, date-time stamp at run-time?
Hi, We would like to see list of all libraries of running application along with their version and date/time stamp (in about window). We would like to get version number of compiled powerbuilder libraries (pbd's) at run-time. I don't know if pibbles compiled in dll format have advanced features (as regular dll - where right clicking on it and selecting properties will allow user to see version number of dll). Anyway, compilation of pibbles in dll format is not an option for us. I would like to see if anybody came across a solution and would like to share it with me. I ...

get date and time
hello i have 2 textbox on my page i want to get date and time in textbox3.text as soon as user enter the partnumber in textbox1.text thanks.   Client or server?  If client-side, are you limited to IE (that is, can you use VBScript)?Peter BrunoneMS MVP, ASP.NETFounder, EasyListBox.comDo the impossible, and go home early....

get time value
i have 2 textbox and a submit button which are txttimefrom, txttimeto..the purpose of these 2 textboxes are to let users key in the, when i click the "submit" button, it will show the total time.... e.g time from = 1420 time to = 1600 so, the total time would be 0140 hours. can anyone help me for this? thank you Hi, Use something like this: C#: DateTime dtFrom = DateTime.ParseExact(txtFrom.Text, "HHmm", CultureInfo.InvariantCulture); DateTime dtTo = DateTime.ParseExact(txtTo.Text, "HHmm", CultureInfo.InvariantCult...

how do i get date time?
i need to collect date time of server. how do i get that date and time. gives date and time of local machine of user browsing our website? and it might be different since user can be from any location. server date time will remain unique and there fore i need to collect server date time so kindly tell me how do i collect server date time.   Depends on where the code is run.  If run at server, it shows server time.  If run at client, it shows client time.  Code is the same either way. JeffPlease: Don't forget to click "Mark as Answer" o...

How to get Date Value
Hi... I have this code, which will returned this: 12/30/2008 12:00:00AM. DateTime dtNow;dtNow = DateTime.Today;   What I wanted is to display the Date only. The date format not following the system date format of yyyy-MM-dd. Any idea? String str = dtNow.ToShortDateString();MAKMark as Answer if this reply helps youMVP ASP/ASP.NetASP.Net Hosting : Host DepotMy Site : ASPSnippets Try out this line DateTime.Today.ToString("yyyy-MM-dd");   Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community ...

Get value of variable
 Hi all, I have a problem such as (C#, webbase, store procedure):1. I have 3 pages (aspx):       +  the fist page (login.aspx): when user Login have 2 variable: user and password      +  the second page (accept term): user modify password and accept term of service, have 3 variable oldpassword, changepassword, term          i use store procedure Update user Set password=@password where mobile=@mobile         Now i want value of variable user in The fist page to update, b...

Web resources about - How to get Date and Time value in a variable - perl.beginners

Variable - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Westpac interest rate rise is one of many variable loan rate rises
WESTPAC is not alone in hitting its owner-occupier customers with a surprise interest rate rise, as dozens of other variable rate home loans ...

Airbnb upgrades variable pricing tool for hosts
Online home rental group Airbnb is rolling out an upgraded variable pricing tool that automatically raises or cuts room rates based on supply ...

Commonwealth Bank raises variable home loan rates
Home owners' mortgage costs are set to rise by hundreds of dollars a year, after the Commonwealth Bank became the latest bank to hike interest ...

CBA lifts variable home loan rates to offset costs associated with stricter capital requirements
The Commonwealth Bank to lift its home loan interest rates independently of the Reserve Bank to partially offset costs associated with stricter ...

Washington Square Signs Spielbergs, Choi Joins Variable and More
... films and an episode of the HBO comedy series "Girls," on which he plays the role of Ray Ploshansky. New York-based creative collective Variable ...

YouTube v10.32 Tweaks Some Interface Elements And Includes Hints About Virtual Reality Content And Variable ...
Forget Update Wednesday! Monday is the new big day. Not only were we treated to the latest M preview release and the official Marshmallow name, ...

"You have to ignore many variables to think women are paid less than men. California is happy to try." ...
Writes Sarah Ketterer in The Wall Street Journal in "The ‘Wage Gap’ Myth That Won’t Die" (which you can get to without subscribing if you Google ...

Staley: 'A lot of different variables...been a hard year'
... 41° Navigation Home Giants A's Sharks Warriors Kings 49ers Raiders Quakes Insiders More Tickets Shop Watch Staley: 'A lot of different variables...been ...

Expert Reveals the Latest Variable Capacity Technology
Learn about gForce Ultra CRAC equipment, the latest variable capacity technology to lower energy usage and increase reliability.

Resources last updated: 12/29/2015 10:55:47 PM