Current Date Script
I am using a current date script on my website which works
fine, but I would like to modify it slightly and am unsure how to
do it. I have tried different scripts but was unsuccessful. Here is
what I am currently using:
<script type="text/javascript">
var d=new Date()
var weekday=new
Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var monthname=new
Array("January","February","March","April","May","June","July","August","September","Octo ber","November","December")
document.write(weekday[d.getDay()] + " ")
document.write(monthname[d.getMonth()] + " ")
document.write(d.getDate() + ", ")
document.write(d.getFullYear())
</script>
As I said, this script works fine. What I would like to do is
instead of having the day display as 1, 2, 3, etc., (December 10,
2007) I would like it to display as 1st, 2nd, 3rd, etc. (December
10th, 2007)
Any help would be appreciated.
The easiest way would be to add another array, like:
var ending=new Array("st","nd","rd","th" ... "st")
where you have all 31 endings for each possible date.
then, on this line:
document.write(d.getDate() + ", ")
change to:
document.write(d.getDate() + ending[d.getDate()-1]+", ")
Paul Davis
http://www.kaosweaver.com/
Visit us for dozens of useful Dreamweaver Extensions.
http://www.communitymx.com/
Partner at Community MX - Extend your knowledge
JaneGarner wrote:
> I am using a current date script on my website which
works fine, but I would
> like to modify it slightly and am unsure how to do it. I
have tried different
> scripts but was unsuccessful. Here is what I am
currently using:
>
> <script type="text/javascript">
> var d=new Date()
> var weekday=new
>
Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
> var monthname=new
>
Array("January","February","March","April","May","June","July","August","Septemb
> er","October","November","December")
> document.write(weekday[d.getDay()] + " ")
> document.write(monthname[d.getMonth()] + " ")
> document.write(d.getDate() + ", ")
> document.write(d.getFullYear())
> </script>
>
> As I said, this script works fine. What I would like to
do is instead of
> having the day display as 1, 2, 3, etc., (December 10,
2007) I would like it to
> display as 1st, 2nd, 3rd, etc. (December 10th, 2007)
> Any help would be appreciated.
>
Similar Messages
-
Increment the version and current date in .ver file
Hi All,
I have the version.ver file and it looks like
[version]
BuildDates=2014.10.01
Script=01
MainVersion=1.00.00.00:01
I want to increment the values and current date if i trigger the build using batch script. The output i need is like this
BuildDates=yy.mm.dd (current date)
Script=02
MainVersion=1.00.00.00:02
Thanks in advanceThanks for your reply. This is my script
@echo off>newfile&setlocal enabledelayedexpansion
:: set up your date here. It probably won't match my format so you'll need to adapt:
set dt=%date:~10,4%.%date:~7,2%.%date:~4,2%
for /f "skip=2 tokens=2,3 delims==:" %%a in ("filename") do (
set v= %%b
set v= !v: 0=!
set /a v+=1
set v=0!v!
set v=!v:~-2!
>>newfile echo SCRIPT=!v!
>>newfile echo BuildDates=%dt%
>>newfile echo MajorVersion=%%a:!v!
goto :aa
:aa
more +3 "filename" >> newfile
del "filename"
ren newfile "filename"
Before execute the script my file will be look like:
version]
BuildDates=date
Script=09
MainVersion=3.00.00.00:09
after executing i am getting the output value as
BuildDates=date
Script=01
MainVersion=19:01
MainVersion=3.00.00.00:09 -
Please help! Looking for script to insert current date on page.
I currently use a Dreamweaver Extension that lets you insert
current date and time on your web page.
The problem is, I don't know Javascript and cannot edit the
Javascript codes to "remove the time"
I only need the current date that will change every day.
Do you know where I can get this script, I goggled and got
several but I'm looking for something authentic.
Also is it possible to have your page validate when you use
Javascript embedded in your HTML?
Thanks everyone,
Patrickquote:
Originally posted by:
Newsgroup User
Webethics wrote:
> The problem is, I don't know Javascript and cannot edit
the Javascript codes
> to "remove the time"
> I only need the current date that will change every day.
JavaScript generates the date by using the clock on the
computer of each
visitor to your site. If a visitor's clock has the wrong
date, your site
will also display the wrong date.
> Do you know where I can get this script, I goggled and
got several but I'm
> looking for something authentic.
I don't know what you mean by "authentic". Date generation in
JavaScript
is one of the most basic features of the language, so if it
works, it's
"authentic".
> Also is it possible to have your page validate when you
use Javascript
> embedded in your HTML?
Yes, but you shouldn't embed JavaScript in XHTML.
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of
ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
So mr. Powers are there people that use Javascript Date in
their page?
Would you recommend it?
I could use PHP but I don't know PHP,
How do I come up with the string in this format, say,
Wednesday, October 29th, 2008 that will change to a new day
according to the server time and date.
Thanks so much for your help and I have two of your books! I
will be taking PHP classes in December.
Patrick -
Future Date Script in Acrobat, 6 months after current date
Hey guys I have been working on this for hours and I am not sure why I cannot figure this out. I am looking to have 1 field box in the form auto populate the current date and another field box to auto populate a date 6 months from the current date. My current date code is attached, I have been playing around with so many variations that I do not want to confuse anyone with my other ugly code fragments.
var bFirstTime=1;
var f=this.getField("todaysDate");
if (bFirstTime=1) {
f.value=util.printd("mm/dd/yyyy",new Date());
bFirstTime=0;
//app.bFirstTime);Have you tried a document level funtction that runs when the PDF is opened. The following script fills in today's date if the field has not been field in and computes the date in 5 months using the parts of the date and the value of today's date.
// one time use document level function
( function () {
// update fields only if balnk
if(this.getField('todaysDate').defaultValue == '') {
// get current date time object
var oNow = new Date();
// get some date parts
var fYear = oNow.getFullYear(); // 4 digit year
var fMonth = oNow.getMonth(); // get zero based month
var fDate = oNow.getDate(); // get date of month
var sFormat = '%,302.0f/%,302.0f/%,304.0f';
// fill in field
this.getField('todaysDate').value = util.printf(sFormat, (fMonth + 1), fDate, fYear);
// make permanent
this.getField('todaysDate').defaultValue = this.getField('todaysDate').value;
// compute date 6 months from today
fMonth += 6;
var oNew = new Date(fYear, fMonth, fDate);
// get some date parts
fYear = oNew.getFullYear(); // 4 digit year
fMonth = oNew.getMonth(); // get zero based month
fDate = oNew.getDate(); // get date of month
// fill in field
this.getField('newDate').value = util.printf(sFormat, (fMonth + 1), fDate, fYear);
// make permanent
this.getField('newDate').defaultValue = this.getField('newDate').value;
// debugging aid
app.alert('dates updated', 2, 0);
} else {
app.alert('dates not updated', 1, 0);
} // end not empty
return;
} // end function
() // call funtion
); // end document level function -
Acrobat 9 - how do you create a dynamic stamp to include the current date (java script)
I have seen my question multiple places and times but the resolutions provided have not worked for me.
I am running Acrobat 9 Pro, cannot run X or XI due to the use of ProSystem fx Engagement.
I want to create what I thought would be a simple stamp. My initials and the current date. i.e. "crm 01/10/13".
Simple right? I created a PDF of my initials. Now I just need the text field with the proper Java Script to insert the date, correct?
I have tried opening "Dynamic.pdf" and copying and pasting the text field that includes the Java Script:
" event.value = (new Date()).toString(); AFDate_FormatEx("h:MM tt, mmm dd, yyyy"); "
The date does not update, it stays static.
I have manually entered the Java Script.
I have edited the Java Script to remove the "Ex".
I have edited the Java Script to revise the "yyyy" to "yy".
I have edited the Java Script to remove the " h:MM tt, " trying different formats to get "dd/mm/yy".
I have selected "Use single-key accelerators to access tools" in Preferences/General.
I have tried PDF files, PNG files. I have created the image files from Word and Excel.
I am at my wits' end. Can someone PLEASE assist me to resolve what should be a simple issue (I hope).
Thank you in advance.Thank you for your response.
Your script works well, but I still have the same issue. The date is remaining static to the system date when the stamp is created. My initial idea was to create a pdf of my initials "crm" and then add the text field with the java script for the date behind my initials. "crm" + (TEXT FIELD with JS). I wanted 3 stamps, red, blue and green. The colors correspond to specific processes in our workflow.
Your script adds my initials as well as the date.
My machine is running Windows 7.
My stamps are located:
C://Documents/Acrobat Stamps/...
Acrobat templates:
C://Program Files (x86)/Adobe/Acrobat 9.0/Acrobat/plug_ins/Annotations/Stamps/ENU/...
I have no problem creating stamps, just a stamp that will use the current system date. I HATE using the typewriter for my initials and the date. I guess I can stamp my initials and then type the date...but what is the point?
Do you have any further thoughts or suggestions?
Thank you very much.
crm 01/11/13 -
A script for adding the current date to file name?
I am working in Indesign CS3. I frequently save file as PDFs into a designated folder. I was hoping for help in writing a script that would apply the current date to the end of the file name, when saved into this folder. Some days, I save the same file several times, into this folder. I was also hoping there was a way to add a date and version, for example "filename_2.25.11(1).pdf" Is this possible? Can someone help me?
ok, I ended up with this test routine:
on adding folder items to this_folder after receiving added_items
tell application "Finder"
repeat with this in added_items
my checkifopened(this)
display dialog (name of this) as text
end repeat
end tell
end adding folder items to
on checkifopened(this)
set a to POSIX path of (this as alias)
repeat until 1 = 0
## don't like that one because it relies on an error msg ... so
(** try
set b to do shell script "lsof | grep " & quoted form of a
on error
exit repeat
end try**)
##so I use this one
set b to do shell script "lsof"
if b does not contain a then
exit repeat
else
say "still opened"
end if
end repeat
end checkifopened
this is a folder action that tests if the added file is still opened by an application... there is no delay between each test-loop since lsof takes some time to execute...
And after adding a timeout (just in case) to this function the final script looks like this:
on adding folder items to thefolder after receiving added_items
tell application "Finder"
set folderkind to kind of thefolder
set myfiles to every item of thefolder whose name does not contain "#" and kind is not folderkind
repeat with myfile in myfiles
set myfile_datestring to my get_datestring(creation date of myfile)
set myfilename to name of myfile
if (count of every character of myfilename) > 4 and (character -4 of myfilename) as text is "." then
set filestatus to my checkifopened(myfile, 60)
if filestatus = false then
display dialog "timeout on folder action"
else
set tmp to ((characters 1 through -5 of myfilename) & "#" & myfile_datestring & (characters -4 through -1 of myfilename)) as text
set myfilename to my checknamewith_pdfsuffix(tmp, thefolder, false)
set name of myfile to myfilename
end if
end if
end repeat
end tell
end adding folder items to
on get_datestring(mydate)
return year of mydate & "-" & (characters -2 through -1 of (("0" & (month of mydate as integer)) as text)) & "-" & (characters -2 through -1 of (("0" & (day of mydate as integer)) as text)) as text
end get_datestring
on checknamewith_pdfsuffix(n, D, looped)
--check if filename exists in D
-- so if "A File.pdf" exists it names it "A File 1.pdf","A File 2.pdf",...
#n = string of the filename
#D = file reference to the directory to check
#looped = boolean used for recursive loop...
tell application "Finder"
set thefiles to name of every item of (D as alias)
end tell
if thefiles contains n then
if looped = false then
set n to ((characters 1 through -5 of n) & "(1)" & (characters -4 through -1 of n)) as text
my checknamewith_pdfsuffix(n, D, true)
else
set tmp to (last word of ((characters 1 through -5 of n) as text) as integer)
set tmpcount to (count of characters of (tmp as text)) + 5
set tmp to tmp + 1
set n to ((characters 1 through (-1 * tmpcount) of n) & "(" & tmp & ")" & (characters -4 through -1 of n)) as text
my checknamewith_pdfsuffix(n, D, true)
end if
else
return n
end if
end checknamewith_pdfsuffix
on checkifopened(this, mytimeout)
## this file reference
## timeout in seconds
set a to POSIX path of (this as alias)
set startdate to current date
repeat until 1 = 0
## don't like that one because it relies on an error msg ... so
(** try
set b to do shell script "lsof | grep " & quoted form of a
on error
exit repeat
end try**)
##so I use this one
set b to do shell script "lsof"
if b does not contain a then
return true
else if ((current date) - startdate) > mytimeout then
return false
else
##say "still opened"
end if
end repeat
end checkifopened
to use this save this script in /Library/Scripts/Folder Action Scripts
and add this as a folder action to your folder...
The script processes all files inside that folder each time a new files is added... -
PowerShell Script to Delete Files Based on Current Date
I know by using Get-Date PowerShell will look at the current date. I would like to make a very basic PS Script which will delete a file older than 8 days based on the current day. I believe using a if/then function will be necessary.
I am very new to scripting so Im not sure how the syntax is written. All help appreciated.Yes, use -Recurse to get subfolders too:
$Folder = "C:\Users\Me\Backups"
Get-ChildItem -Path $Folder -Recurse |
Where { $_.LastWriteTime -lt [DateTime]::Today.AddDays(-8) } |
Sort LastWriteTime |
Remove-Item $_ -Force -Confirm:$false
Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable) _________________________________________________________________________________
Powershell: Learn it before it's an emergency http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx -
I have a document javascript that used to work. It prints the current date upon first opening the PDF into a field called Today. Thereafter, the date does not change no matter how many more times the PDF is opened.
var f = this.getField("Today");
if (f.value == "") f.value = util.printd("mm/dd/yyyy", new Date());
I'm using Acrobat 9 Pro, and for some reason this script no longer works in version 9. If anyone can assist to correct this sript, I would greatly appreciate it.It works fine for me in Acrobat 9.2.0 (under Windows 7). If the field is empty when the form opens, it inserts the current date. If the field is not empty, it does not do anything.
Are you absolutely sure that the field 'Today' is empty when you open the PDF? -
"Exp" utility script with current date dmp file format
Dear All,
I want to creat a window batch file script "oralce database 11gr2" in such a way that dmp file automatically created in c:\test folder with oralce _sid and current date.
C:> exp file=c:\test\ora-sid_date_format.dmp owner=test
Any help would be appreciated.
Regards,Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\comp>exp system/sm file=c:\%ORACLE_SID%_%date%_forma
t.dmp owner=test
^C
C:\Documents and Settings\comp>exp system/sm@test file=c:\%ORACLE_SID%_%date%_
format.dmp owner=test
Export: Release 10.2.0.2.0 - Production on Wed May 19 12:41:11 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit
Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
About to export specified users ...
. exporting pre-schema procedural objects and actions
. exporting foreign function library names for user TEST
. exporting PUBLIC type synonyms
. exporting private type synonyms
. exporting object type definitions for user TEST
About to export TEST's objects ...
. exporting database links
. exporting sequence numbers
. exporting cluster definitions
. about to export TEST's tables via Conventional Path ...
. . exporting table AGENTSINFO 7 rows exported
. . exporting table ARCHIVE_SETT 3 rows exported
. . exporting table ARC_CPAYMENT 0 rows exported
. . exporting table ARC_CREDIT 2596 rows exported
. . exporting table ARC_DEBET 4 rows exported
. . exporting table ARC_DPAYMENT 4 rows exported
. . exporting table BRANCHESCASH 2 rows exported
. . exporting table CANCELCOUPON_OPRCODES 17 rows exported
. . exporting table CHECK_PAYMENTREQUEST 36 rows exported
. . exporting table CORPCODES 0 rows exported
. . exporting table CREDIT_MESS 0 rows exported
. . exporting table CREDIT_PAYMENT 0 rows exported
. . exporting table CURRENCIES 1 rows exported
. . exporting table DEBET_MESS 0 rows exported
. . exporting table DEBET_PAYMENT 0 rows exported
. . exporting table DIRECTORY 1 rows exported
. . exporting table MAILSETTINGS 2 rows exported
. . exporting table PAYCOUPON_OPRCODES 22 rows exported
. . exporting table PAYMENT_OPRCODES 21 rows exported
. . exporting table PAYMENT_REQUEST 53 rows exported
. . exporting table PAYMENT_RESPONSE 53 rows exported
. . exporting table REP_CANCELCOUPON 0 rows exported
. . exporting table REP_PAYCOUPON 70 rows exported
. . exporting table REP_VERIFYCOUPON 121 rows exported
. . exporting table REQ_CANCELCOUPON 0 rows exported
. . exporting table REQ_PAYCOUPON 108 rows exported
. . exporting table REQ_VERIFYCOUPON 124 rows exported
. . exporting table VERIFYCOUPON_OPRCODES 18 rows exported
. exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting referential integrity constraints
. exporting triggers
. exporting indextypes
. exporting bitmap, functional and extensible indexes
. exporting posttables actions
. exporting materialized views
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
. exporting post-schema procedural objects and actions
. exporting statistics
Export terminated successfully without warnings.
C:\Documents and Settings\chinar>date
The current date is: 19.05.2010
Enter the new date: (dd-mm-yy)
C:\Documents and Settings\comp>SET ORACLE_SID
ORACLE_SID=SB
C:\Documents and Settings\comp>
and result is SB_19.05.2010_format.dmp -
Can I make a checkbox populate the current date?
I've been asked to make a form that has quite a few checkboxes. These checkboxes also need to be marked with a date when checked off.
Rather than have the person filling out the form type the date every time they check the box, they request that when the user clicks the checkbox that a current date show next to the checkbox.
I don't know if this can be done with a current date stamp or with having a text box that populates with the current date, etc.
The forms are also going to be used throughout multiple days, so I can't just call on a "current date" and show/hide that text box like I had originally thought to do.
I'm also really green to scripting so any help or guidance in the right direction would be much appreciated.
Thank you.The following Mouse Up script for a check box will set the associated text field to the current data when it's selected, and blank the field when not:
// Mouse Up script for check box
(function () {
// Get a reference to the text field
var f = getField("text1");
// Set the value of the text field
if (event.target.value !== "Off") {
f.value = util.printd("mm/dd/yyyy", new Date());
} else {
f.value = "";
Replace "text1" with the name of the associated text field. -
How to reference application version number and current date in page footer
Am new to Apex and am creating first app for production users on Apex 4.0.1 ... I notice that Application Builder app itself displays the version number at bottom right of screen .. are there any substitution strings that I can use to get current date and application version in my own Apex app ... or do I need to create e.g Javascript to format the date and create my own substitution string ?
Any help much appreciated .. thanks !I modified the Footer of our Default page template. Used JavaScript for the date, below is the code we use. The very last table is specific to our environment and it would need to be customized for your use or removed if not needed. I am a JavaScript novice so this may be crude but it does the job.
Jeff
<table width="100%" cellpadding="0" cellspacing="0"
border="0">
<tr>
<td width="500">
<script Language="JavaScript">
<!--
function GetDay(nDay)
var Days = new Array("Sunday","Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday");
return Days[nDay]
function GetMonth(nMonth)
var Months = new Array("January","February","March","April","May","June",
"July","August","September","October","November","December");
return Months[nMonth]
function GetTime () {
var curtime = new Date();
var curhour = curtime.getHours();
var curmin = curtime.getMinutes();
var cursec = curtime.getSeconds();
var time = "";
if(curhour == 0) curhour = 12;
time = (curhour > 12 ? curhour - 12 : curhour) + ":" +
(curmin < 10 ? "0" : "") + curmin + ":" +
(cursec < 10 ? "0" : "") + cursec + " " +
(curhour > 12 ? "PM" : "AM");
return time;
function DateString()
var Today = new Date();
var suffix = "th";
switch (Today.getDate())
case 1:
case 21:
case 31:
suffix = "st"; break;
case 2:
case 22:
suffix = "nd"; break;
case 3:
case 23:
suffix = "rd"; break;
var strDate = GetDay(Today.getDay()) + " - " + GetMonth(Today.getMonth()) + " " + Today.getDate(); strDate += suffix + ", " + Today.getFullYear() + " " ;
return strDate
//-->
</script>
<script Language="JavaScript">
<!--
document.write(DateString() + GetTime());
//-->
</script>
</td>
<td width="300" class="fineprint"><div align="right">
</div></td>
<td width="900" class="fineprint"><div align="right">
&APP_USER.
#APP_VERSION#
</div></td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0"
border="0">
<tr>
<td width="33%" align="left" valign="bottom"><img
src="#WORKSPACE_IMAGES#iconseal-rust.gif" alt="NH State Seal" width="25"
height="25" /></td>
<td width="33%" align="center" valign="bottom"><a href="http://www.nh.gov/" class="fineprint">NH.gov</a>
<a href="http://www.nh.gov/disclaimer.html"
class="fineprint">Privacy Policy</a> <a
href="http://www.nh.gov/wai/index.html" class="fineprint">Accessibility
Policy</a></td>
<td width="33%" class="fineprint"><div align="right">Copyright © State of
New Hampshire, 2007-2010</div></td>
</tr>
</table><br />
#FORM_CLOSE#
</body>
</html> -
OWL with Default Set containting Current Date as query parameter
Hello Everybody,
I have a custom BO which mainly consists of a name and a time period (start and end date).
Now I'd like to create a Default set like
"Give me all objects with today between start and end date."
I already tried the following:
Filling a field using UI-Scripting:
$data.UIState.Today = $controller.DateTimeUtils.DateNow;
Copy the field into the search parameter
executing the query with this search parameter.
However, I using this approach, I only managed to search for objects matching exactly todays date, but not using greater/lower comparators.
Furthermore I also searched for a field transformation giving me the current date but did not succeed.
Does anyone have any ideas how to achieve this or how to get one of the above ideas to work?
Best regards,
LudgerHello Ludger,
That`s what I expected: The fields do not define the interval.
Therefore you need to define it by yourself via this "less or equal".
What you can do in the UI Designer at the query definition is to provide an interval
For the field "CurrentDate" provide
- SelectOption = "between"
- Low Value = your start date
- High Value = your end date
- Select Option = "include"
HTH,
Horst -
Adobe LiveCycle Designer 8 - Add days to Current Date in another text field
Hi-
I am working on an expense report. I have six fields, CurrentDate, and countDate1 through countDate5. The CurrentDate is a Time/Date field which the user can select whatever date is needed with the drop down calendar. The other five countDate fields are "text" fields which will represent Monday through Friday. I would like to add zero days to whatever the user selects as the CurrentDate and make that appear in countDate1 which represents Monday(the CurrentDate the user selects will always be a Monday), add one day to whatever the user selects as the CurrentDate and make that appear in countDate2 which represents Tuesday...and so on. I realize this is probably basic for someone familiar with FormCalc but I'm very new at this.
This got me very close but I want the user to select the date and not have the CurrentDate already filled in.
CurrentDate - DateTime field, FormCalc calculation script:
num2date(Date())
Date1 - Text field, FormCalc calculation script:
Num2Date( Date2Num(CurrentDate.formattedValue))
Date2 - Text field, FormCalc calculation script:
Num2Date( Date2Num(CurrentDate.formattedValue) + 1 )
Thanks!
BrianHere is an exmaple of adding days the script is used in the "exit" event for the date select field that has display format of "MM/DD/YYYY". Adding days requires add x number of days to the days since the epoch date for the current date, adding months or years one needs to manipulate the string parts of the date.
----- form1.#subform[0].InputDateField::exit: - (FormCalc, client) ---------------------------------
// fomatted string for selected date
var sFmtDateValue = $.formattedValue
var sMsg = Concat("Entered date formatted: ", sFmtDateValue) // build message string
sMsg = Concat(sMsg, "\u000a" ) // add new line to message
// convert date string to days since epoch date - format is important
var fDaysPast = Date2Num(sFmtDateValue, "MM/DD/YYYY")
// add 7 days to days past epoch date
var f7DaysPlus = fDaysPast + 7 // add 7 days
var s7DaysPlus = Num2Date(f7DaysPlus, "MMM DD, YYYY") // format string for 7 days plus
sMsg = Concat(sMsg, "\u000a", "Plus 7 Days: ", s7DaysPlus) // build message string
// add 14 days to days past epoch date
var f14DaysPlus = fDaysPast + 14 // add 7 days
var s14DaysPlus = Num2Date(f14DaysPlus, "MMMM DD, YYYY") // format string for 7 days plus
sMsg = Concat(sMsg, "\u000a", "Plus 14 Days: ", s14DaysPlus) // build message string
// display results
// work on months
// get parts of date past epoch date
var sFullYear = Num2Date(fDaysPast, "YYYY") // get 4 digit year form days past epoch date
var sMonth = Num2Date(fDaysPast, "MM") // get month form days past epoch date as number
var sDate = Num2Date(fDaysPast, "DD") // get date form days past epoch date as a number
var s2Month = Sum(sMonth, 2) // add 2 months
var s2FullYear = sFullYear
// if more than 12 months in new date adjust year on number of months
if (s2Month > "12") then
s2FullYear = Sum(s2FullYear, + 1) // increment year
s2Month = Sum(s2Month, - 12) // adjsut months
endif
var s2MonthsAdded = Concat(s2Month, "/", sDate, "/", s2FullYear) // date string
sMsg = Concat(sMsg, "\u000a", "Added 2 months: ", s2MonthsAdded) // display stringxfa.host.messageBox(sMsg, "Sample Adding Days" ,3, 0);
var s5Month = Sum(sMonth, 5) // add 5 months
var s5FullYear = sFullYear
// if more than 12 months in new date adjust year on number of months
if (s5Month > "12") then
s5FullYear = Sum(s5FullYear, + 1) // increment year
s5Month = Sum(s5Month, - 12) // adjsut months
endif
var s5MonthsAdded = Concat(s5Month, "/", sDate, "/", s5FullYear) //build Date string
sMsg = Concat(sMsg, "\u000a", "Added 5 months: ", s5MonthsAdded) // display stringxfa.host.messageBox(sMsg, "Sample Adding Days" ,3, 0);
// display results
xfa.host.messageBox(sMsg, "Sample Adding Days and Months" ,3, 0); -
How do I use AppleScript to Change the Creation Date to the Current Date?
I sorted my downloads folder by creation date and found that the items were sorted seemingly randomly. On closer inspection, I saw that the creation dates were not the same as the dates that I downloaded the items, so I figures that Snow Leopard was using the date given to it by the server.
In order to get the items sorted by download date, I figured I'd use Hazel, but it doesn't have a “change creation date” item. It does, however, have an “run AppleScript” item.
So my question is this: how do I use AppleScript to change the creation date of an item to the current date?TC (Techno Cat) wrote:
Okay, I tried changing the creation date with SetFile, but it kept giving me an error:
What am I doing wrong?
Looks like the date and time was not quoted
Try this Applescript. It will change the creation date of every file in the Downloads folder to the current date and time:
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #E6E6EE;
overflow: auto;"
title="this text can be pasted into the AppleScript Editor">
set current_date_and_time to do shell script "date \"+%m/%d/%Y %H:%M\""
tell application "Finder"
set filelist to every file of the alias (the path to downloads folder as text)
repeat with currentFile in filelist
do shell script "/usr/bin/SetFile -d " & quoted form of current_date_and_time & space & quoted form of POSIX path of (currentFile as string)
end repeat
end tell</pre> -
Check the modification date of a file and compare it to the current date
Hey everyone,
I'm writing a script that compares the modification date of a file to the current date, and performs actions based on whether the file was modified 7 days ago or not. I haven't been able to figure out exactly how to do this.
I haven't been able to find much in the way of this online, and I am not that familiar with manipulating dates and whatnot. I was able to get a bit of it, posted below:
currentDate=`date +%b-%d`
fileDate=`ls -l ~/.backup.txt | awk '{ print $6, $7 }'`
echo "$fileDate"
echo "$currentDate"
if [ "$fileDate" <= "$currentDate" ]; then
echo "old enough to run script"
else
echo "not old enough yet"
fi
Of course, this doesn't work. Any help would be much appreciated. This is for Leopard.
TIA,
Andrewfind ~/.backup.txt -mtime +7 -exec yourscript {} ;
You may need to play with the +7 value to get the exact number of days old the file needs to be.
The find command will accept a directory (actually it is frequently used with directories) and will find all files in that directory and any subdirectories below that match the find selection critiera.
So you could do something like
find ~ -mtime +7 | xargs yourscript
or
find ~ -mtime +7 -name "*.txt" | xargs yourscript
and if your script does not accept multiple filenames on the command line, you can use
find ~ -mtime +7 | xargs -n 1 yourscript
and if your file names have spaces in them, you can use
find ~ -mtime +7 -print0 | xargs -0 -n 1 yourscript
Maybe you are looking for
-
ST05: different ways to analyze SQL trace, different authority checks
Hi there, Here is the issue I faced. I need to analyze SQL statement for example. I can do it two ways: 1) run ST05> Enter SQL statement> Explain or via trace itself: 2) run ST05> Display trace> Explain The thing is that when doing it the second way
-
Process chains issue:very urgent
Hi All, This issue is related to process chains.Last weekend our Basis team changed the BW PRD from BWBPRD to BWBPRD1.The process chains were schedlued previously on BWBPRD, so after the server change none of the process chains were triggered. We hav
-
Re: Using simple java class in an .war file.
Hi All, I have a simple question, Can I access an simple java class from a jsp file that I have written by putting it in the "classes" folder?? What entry should go in the web.xml file? Here is my directory structure: sample.war | ----test.jsp <file>
-
How to create a root category in OLM catalog?
How do we create a root category in the OLM catalog? We are on R12.
-
So I try to sync my itunes to my ipod. About 1 out of 7 sync properly and the remainder have the error message icon next to them. I delete all of the bad songs from my ipod and try to manually upload them again - same thing. All of my songs play corr