Page 1 of 1

get date formated

Posted: Sat Apr 08, 2017 8:23 pm
by gurusonwheels
im trying to get the date and time in a variable
that i can use as part of a filename that will not
have invalided character for a email attachment .

not seeing a format in the dict that uses underscores or dashes .

Re: get date formated

Posted: Sat Apr 08, 2017 8:27 pm
by Klaus
What about:
...
replace ":" with "_" in your_date_variable
...
And/or:
...
replace "/" with "_" in your_date_variable
...
You get the picture. :D

Re: get date formated

Posted: Sat Apr 08, 2017 8:36 pm
by gurusonwheels
yep thanks :D

Re: get date formated

Posted: Sun Apr 09, 2017 9:02 am
by AxWald
Hi,

you could also try this:

Code: Select all

   convert the seconds to dateitems
   put item 1 of it & format("%02s",item 2 of it) & \
         format("%02s",item 3 of it) & format("%02s",item 4 of it) & \
         format("%02s",item 5 of it) into myTS
   put "DateItems: " & it & CR & "TimeStamp: " & myTS
(shows some useful features ;-) )

Have fun!

Re: get date formated

Posted: Sun Apr 09, 2017 10:36 am
by MaxV
Just use the urlencode function: http://livecode.wikia.com/wiki/URLEncode

Code: Select all

put urlencode (THE LONG DATE  & the LONG time )

Sunday%2C+April+9%2C+201711%3A39%3A43+AM

or

Code: Select all

put urlencode (THE internet DATE  )
Sun%2C+9+Apr+2017+11%3A57%3A06+%2B0200

or even better:

Code: Select all

put the seconds
1491731863

See http://livecode.wikia.com/wiki/Seconds

Re: get date formated

Posted: Sun Apr 09, 2017 11:14 am
by Thierry
AxWald wrote:
you could also try this:

Code: Select all

   convert the seconds to dateitems
   put item 1 of it & format("%02s",item 2 of it) & \
         format("%02s",item 3 of it) & format("%02s",item 4 of it) & \
         format("%02s",item 5 of it) into myTS
   put "DateItems: " & it & CR & "TimeStamp: " & myTS
(shows some useful features ;-) )

Have fun!
A slightly different typing but same as yours:

Code: Select all

convert the seconds to dateitems
put "DateItems: " & IT into R
get format( "TimeStamp: %4d%02s%02s%02s%02s", \
         item 1 of IT,  \
         item 2 of IT,  \
         item 3 of IT,  \
         item 4 of IT,  \
         item 5 of IT )
put R &cr& IT
Have even more fun :)

Regards,

Thierry

Re: get date formated

Posted: Sun Apr 09, 2017 11:30 am
by Klaus
Guys, sometimes you are like: https://www.youtube.com/watch?v=2DmE8-Xg0Kg
:D :D :D

Re: get date formated

Posted: Mon Apr 10, 2017 9:17 am
by Klaus
Bonjour Thierry,

your last post was nothing that you had to delete!? :shock:


Best

Klaus