Page 1 of 1

How to add datetime to an input at playback

Posted: Fri Oct 21, 2011 2:48 pm
by Gav
Hi,

I have an input field that I want to type "cheese" into. Is there a way I could add the current datetime so that when the recording plays back it inputs "cheese20111021-14:46:23"? I imagine it'll have something to do with variables, but I'm not sure how to go about doing that.

Thanks,

Gav

Re: How to add datetime to an input at playback

Posted: Fri Oct 21, 2011 3:49 pm
by Ciege
Are you using the Recorder or your own code?

Re: How to add datetime to an input at playback

Posted: Fri Oct 21, 2011 4:47 pm
by Gav
Hi Ciege,

It doesn't really matter how the step gets into the recording (sometimes I record, sometimes I add manually if the edit box is already in the repo). All I need it to do is append something to the end of my original input. I'm ideally wanting something unique, so datetime, or seconds/milliseconds.

Gav

Re: How to add datetime to an input at playback

Posted: Fri Oct 21, 2011 5:11 pm
by Ciege
OK, well then you can add code similar to this:

Code: Select all

strYear = System.DateTime.Now.Year.ToString();
strMonth = System.DateTime.Now.ToString("MM");
strDay = System.DateTime.Now.ToString("dd");
strHour = System.DateTime.Now.ToString("hh");
strMinute = System.DateTime.Now.ToString("mm");
strSecond = System.DateTime.Now.ToString("ss");

strDateTimeStamp = strYear + "_" + strMonth + "_" + strDay + "___" + strHour + "_" + strMinute + "_" + strSecond;
Then your input variable would be:

Code: Select all

"Cheese" + strDateTimeStamp;