get date formated

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
gurusonwheels
Posts: 31
Joined: Sat Apr 01, 2017 5:15 pm

get date formated

Post by gurusonwheels » Sat Apr 08, 2017 8:23 pm

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 .

Klaus
Posts: 11313
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: get date formated

Post by Klaus » Sat Apr 08, 2017 8:27 pm

What about:
...
replace ":" with "_" in your_date_variable
...
And/or:
...
replace "/" with "_" in your_date_variable
...
You get the picture. :D

gurusonwheels
Posts: 31
Joined: Sat Apr 01, 2017 5:15 pm

Re: get date formated

Post by gurusonwheels » Sat Apr 08, 2017 8:36 pm

yep thanks :D

AxWald
Posts: 369
Joined: Thu Mar 06, 2014 2:57 pm

Re: get date formated

Post by AxWald » Sun Apr 09, 2017 9:02 am

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!
Livecode programming until the cat hits the fan ...

MaxV
Posts: 1574
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: get date formated

Post by MaxV » Sun Apr 09, 2017 10:36 am

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
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 664
Joined: Wed Nov 22, 2006 3:42 pm
Location: France
Contact:

Re: get date formated

Post by Thierry » Sun Apr 09, 2017 11:14 am

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
Thierry Douez - https://sunny-tdz.com
Pourquoi tant de notes lorsqu'il suffit de jouer les plus belles... [Barbara]

Klaus
Posts: 11313
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: get date formated

Post by Klaus » Sun Apr 09, 2017 11:30 am

Guys, sometimes you are like: https://www.youtube.com/watch?v=2DmE8-Xg0Kg
:D :D :D

Klaus
Posts: 11313
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: get date formated

Post by Klaus » Mon Apr 10, 2017 9:17 am

Bonjour Thierry,

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


Best

Klaus

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”